aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--components/constellation/constellation.rs6
-rw-r--r--components/net/filemanager_thread.rs1
-rw-r--r--components/net_traits/filemanager_thread.rs5
-rw-r--r--components/script/dom/file.rs2
-rw-r--r--tests/unit/net/filemanager_thread.rs34
-rw-r--r--tests/unit/net/lib.rs1
6 files changed, 46 insertions, 3 deletions
diff --git a/components/constellation/constellation.rs b/components/constellation/constellation.rs
index f595b4f6573..bbe25acc401 100644
--- a/components/constellation/constellation.rs
+++ b/components/constellation/constellation.rs
@@ -38,6 +38,7 @@ use msg::constellation_msg::{SubpageId, WindowSizeData, WindowSizeType};
use msg::constellation_msg::{self, PanicMsg};
use msg::webdriver_msg;
use net_traits::bluetooth_thread::BluetoothMethodMsg;
+use net_traits::filemanager_thread::FileManagerThreadMsg;
use net_traits::image_cache_thread::ImageCacheThread;
use net_traits::storage_thread::StorageThreadMsg;
use net_traits::{self, ResourceThreads, IpcSend};
@@ -850,6 +851,11 @@ impl<LTF: LayoutThreadFactory, STF: ScriptThreadFactory> Constellation<LTF, STF>
if let Err(e) = self.resource_threads.send(StorageThreadMsg::Exit) {
warn!("Exit storage thread failed ({})", e);
}
+
+ if let Err(e) = self.resource_threads.send(FileManagerThreadMsg::Exit) {
+ warn!("Exit storage thread failed ({})", e);
+ }
+
if let Err(e) = self.bluetooth_thread.send(BluetoothMethodMsg::Exit) {
warn!("Exit bluetooth thread failed ({})", e);
}
diff --git a/components/net/filemanager_thread.rs b/components/net/filemanager_thread.rs
index f2cdc658b37..bf546c80636 100644
--- a/components/net/filemanager_thread.rs
+++ b/components/net/filemanager_thread.rs
@@ -53,6 +53,7 @@ impl FileManager {
FileManagerThreadMsg::SelectFiles(sender) => self.select_files(sender),
FileManagerThreadMsg::ReadFile(sender, id) => self.read_file(sender, id),
FileManagerThreadMsg::DeleteFileID(id) => self.delete_fileid(id),
+ FileManagerThreadMsg::Exit => break,
}
}
}
diff --git a/components/net_traits/filemanager_thread.rs b/components/net_traits/filemanager_thread.rs
index ee4fdb291cf..2ced0701eff 100644
--- a/components/net_traits/filemanager_thread.rs
+++ b/components/net_traits/filemanager_thread.rs
@@ -6,7 +6,7 @@ use ipc_channel::ipc::IpcSender;
use std::path::PathBuf;
use uuid::Uuid;
-#[derive(Deserialize, Serialize)]
+#[derive(Debug, Deserialize, Serialize)]
pub struct SelectedFile {
pub id: Uuid,
pub filename: PathBuf,
@@ -28,6 +28,9 @@ pub enum FileManagerThreadMsg {
/// Delete the FileID entry
DeleteFileID(Uuid),
+
+ /// Shut down this thread
+ Exit,
}
pub type FileManagerResult<T> = Result<T, FileManagerThreadError>;
diff --git a/components/script/dom/file.rs b/components/script/dom/file.rs
index 62e1b0a95bd..f566b4426b4 100644
--- a/components/script/dom/file.rs
+++ b/components/script/dom/file.rs
@@ -51,8 +51,6 @@ impl File {
pub fn new_from_selected(window: &Window, selected: SelectedFile) -> Root<File> {
let name = DOMString::from(selected.filename.to_str().expect("File name encoding error"));
- // FIXME: fix this after PR #11221 is landed
- let id = selected.id;
let slice = DataSlice::empty();
let global = GlobalRef::Window(window);
diff --git a/tests/unit/net/filemanager_thread.rs b/tests/unit/net/filemanager_thread.rs
new file mode 100644
index 00000000000..eb4ce535007
--- /dev/null
+++ b/tests/unit/net/filemanager_thread.rs
@@ -0,0 +1,34 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+use ipc_channel::ipc::{self, IpcSender};
+use net::filemanager_thread::FileManagerThreadFactory;
+use net_traits::filemanager_thread::{FileManagerThreadMsg, FileManagerThreadError};
+
+#[test]
+fn test_filemanager() {
+ let chan: IpcSender<FileManagerThreadMsg> = FileManagerThreadFactory::new();
+
+ {
+ let (tx, rx) = ipc::channel().unwrap();
+ let _ = chan.send(FileManagerThreadMsg::SelectFile(tx));
+
+ match rx.recv().unwrap() {
+ Err(FileManagerThreadError::InvalidSelection) => {},
+ _ => assert!(false, "Should be an invalid selection before dialog is implemented"),
+ }
+ }
+
+ let _ = chan.send(FileManagerThreadMsg::Exit);
+
+ {
+ let (tx, rx) = ipc::channel().unwrap();
+ let _ = chan.send(FileManagerThreadMsg::SelectFile(tx));
+
+ match rx.try_recv() {
+ Ok(_) => assert!(false, "The thread should not response fine after exited"),
+ Err(_) => {},
+ }
+ }
+}
diff --git a/tests/unit/net/lib.rs b/tests/unit/net/lib.rs
index ac06bc1f1c0..4a22213baa6 100644
--- a/tests/unit/net/lib.rs
+++ b/tests/unit/net/lib.rs
@@ -29,3 +29,4 @@ extern crate util;
#[cfg(test)] mod resource_thread;
#[cfg(test)] mod hsts;
#[cfg(test)] mod http_loader;
+#[cfg(test)] mod filemanager_thread;