servo: Merge #10485 - Implement stub for NavigatorPlugins (from cbrewster:navigator_plugins); r=Ms2ger
authorConnor Brewster <brewsterc@my.caspercollege.edu>
Mon, 11 Apr 2016 20:47:46 +0500
changeset 338474 0bdab191226e3c458469636d459e70b84b3e3798
parent 338473 0b7a4788dea932a5e7f1c8829088afbabced7ec3
child 338475 39a8bea6d01b9debe27900245827cbf1dba6ff8b
push id31307
push usergszorc@mozilla.com
push dateSat, 04 Feb 2017 00:59:06 +0000
treeherdermozilla-central@94079d43835f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersMs2ger
servo: Merge #10485 - Implement stub for NavigatorPlugins (from cbrewster:navigator_plugins); r=Ms2ger This PR implements stub for NavigatorPlugins as outlined in #9991. r? @jdm Source-Repo: https://github.com/servo/servo Source-Revision: 3b7e426d33e539303f46a0a153752683838186fc
servo/components/script/dom/mimetype.rs
servo/components/script/dom/mimetypearray.rs
servo/components/script/dom/mod.rs
servo/components/script/dom/navigator.rs
servo/components/script/dom/plugin.rs
servo/components/script/dom/pluginarray.rs
servo/components/script/dom/webidls/MimeType.webidl
servo/components/script/dom/webidls/MimeTypeArray.webidl
servo/components/script/dom/webidls/Navigator.webidl
servo/components/script/dom/webidls/Plugin.webidl
servo/components/script/dom/webidls/PluginArray.webidl
new file mode 100644
--- /dev/null
+++ b/servo/components/script/dom/mimetype.rs
@@ -0,0 +1,36 @@
+/* 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 dom::bindings::codegen::Bindings::MimeTypeBinding::MimeTypeMethods;
+use dom::bindings::js::Root;
+use dom::bindings::reflector::{Reflector};
+use dom::plugin::Plugin;
+use util::str::DOMString;
+
+#[dom_struct]
+pub struct MimeType {
+    reflector_: Reflector,
+}
+
+impl MimeTypeMethods for MimeType {
+    // https://html.spec.whatwg.org/multipage/#dom-mimetype-type
+    fn Type(&self) -> DOMString {
+        unreachable!()
+    }
+
+    // https://html.spec.whatwg.org/multipage/#dom-mimetype-description
+    fn Description(&self) -> DOMString {
+        unreachable!()
+    }
+
+    // https://html.spec.whatwg.org/multipage/#dom-mimetype-suffixes
+    fn Suffixes(&self) -> DOMString {
+        unreachable!()
+    }
+
+    // https://html.spec.whatwg.org/multipage/#dom-mimetype-enabledplugin
+    fn EnabledPlugin(&self) -> Root<Plugin> {
+        unreachable!()
+    }
+}
new file mode 100644
--- /dev/null
+++ b/servo/components/script/dom/mimetypearray.rs
@@ -0,0 +1,62 @@
+/* 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 dom::bindings::codegen::Bindings::MimeTypeArrayBinding;
+use dom::bindings::codegen::Bindings::MimeTypeArrayBinding::MimeTypeArrayMethods;
+use dom::bindings::global::GlobalRef;
+use dom::bindings::js::Root;
+use dom::bindings::reflector::{Reflector, reflect_dom_object};
+use dom::mimetype::MimeType;
+use util::str::DOMString;
+
+#[dom_struct]
+pub struct MimeTypeArray {
+    reflector_: Reflector,
+}
+
+impl MimeTypeArray {
+    pub fn new_inherited() -> MimeTypeArray {
+        MimeTypeArray {
+            reflector_: Reflector::new()
+        }
+    }
+
+    pub fn new(global: GlobalRef) -> Root<MimeTypeArray> {
+        reflect_dom_object(box MimeTypeArray::new_inherited(),
+                           global,
+                           MimeTypeArrayBinding::Wrap)
+    }
+}
+
+impl MimeTypeArrayMethods for MimeTypeArray {
+    // https://html.spec.whatwg.org/multipage/#dom-mimetypearray-length
+    fn Length(&self) -> u32 {
+        0
+    }
+
+    // https://html.spec.whatwg.org/multipage/#dom-mimetypearray-item
+    fn Item(&self, _index: u32) -> Option<Root<MimeType>> {
+        None
+    }
+
+    // https://html.spec.whatwg.org/multipage/#dom-mimetypearray-nameditem
+    fn NamedItem(&self, _name: DOMString) -> Option<Root<MimeType>> {
+        None
+    }
+
+    // https://html.spec.whatwg.org/multipage/#dom-mimetypearray-item
+    fn IndexedGetter(&self, _index: u32, _found: &mut bool) -> Option<Root<MimeType>> {
+        None
+    }
+
+    // check-tidy: no specs after this line
+    fn NamedGetter(&self, _name: DOMString, _found: &mut bool) -> Option<Root<MimeType>> {
+        None
+    }
+
+    // https://heycam.github.io/webidl/#dfn-supported-property-names
+    fn SupportedPropertyNames(&self) -> Vec<DOMString> {
+        vec![]
+    }
+}
--- a/servo/components/script/dom/mod.rs
+++ b/servo/components/script/dom/mod.rs
@@ -337,25 +337,29 @@ pub mod htmltitleelement;
 pub mod htmltrackelement;
 pub mod htmlulistelement;
 pub mod htmlunknownelement;
 pub mod htmlvideoelement;
 pub mod imagedata;
 pub mod keyboardevent;
 pub mod location;
 pub mod messageevent;
+pub mod mimetype;
+pub mod mimetypearray;
 pub mod mouseevent;
 pub mod namednodemap;
 pub mod navigator;
 pub mod navigatorinfo;
 pub mod node;
 pub mod nodeiterator;
 pub mod nodelist;
 pub mod performance;
 pub mod performancetiming;
+pub mod plugin;
+pub mod pluginarray;
 pub mod processinginstruction;
 pub mod progressevent;
 pub mod radionodelist;
 pub mod range;
 pub mod screen;
 pub mod servohtmlparser;
 pub mod servoxmlparser;
 pub mod storage;
--- a/servo/components/script/dom/navigator.rs
+++ b/servo/components/script/dom/navigator.rs
@@ -3,31 +3,37 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 use dom::bindings::codegen::Bindings::NavigatorBinding;
 use dom::bindings::codegen::Bindings::NavigatorBinding::NavigatorMethods;
 use dom::bindings::global::GlobalRef;
 use dom::bindings::js::{JS, MutNullableHeap, Root};
 use dom::bindings::reflector::{Reflector, Reflectable, reflect_dom_object};
 use dom::bluetooth::Bluetooth;
+use dom::mimetypearray::MimeTypeArray;
 use dom::navigatorinfo;
+use dom::pluginarray::PluginArray;
 use dom::window::Window;
 use util::str::DOMString;
 
 #[dom_struct]
 pub struct Navigator {
     reflector_: Reflector,
     bluetooth: MutNullableHeap<JS<Bluetooth>>,
+    plugins: MutNullableHeap<JS<PluginArray>>,
+    mime_types: MutNullableHeap<JS<MimeTypeArray>>,
 }
 
 impl Navigator {
     fn new_inherited() -> Navigator {
         Navigator {
             reflector_: Reflector::new(),
             bluetooth: Default::default(),
+            plugins: Default::default(),
+            mime_types: Default::default(),
         }
     }
 
     pub fn new(window: &Window) -> Root<Navigator> {
         reflect_dom_object(box Navigator::new_inherited(),
                            GlobalRef::Window(window),
                            NavigatorBinding::Wrap)
     }
@@ -73,9 +79,24 @@ impl NavigatorMethods for Navigator {
     fn Bluetooth(&self) -> Root<Bluetooth> {
         self.bluetooth.or_init(|| Bluetooth::new(self.global().r()))
     }
 
     // https://html.spec.whatwg.org/multipage/#navigatorlanguage
     fn Language(&self) -> DOMString {
         navigatorinfo::Language()
     }
+
+    // https://html.spec.whatwg.org/multipage/#dom-navigator-plugins
+    fn Plugins(&self) -> Root<PluginArray> {
+        self.plugins.or_init(|| PluginArray::new(self.global().r()))
+    }
+
+    // https://html.spec.whatwg.org/multipage/#dom-navigator-mimetypes
+    fn MimeTypes(&self) -> Root<MimeTypeArray> {
+        self.mime_types.or_init(|| MimeTypeArray::new(self.global().r()))
+    }
+
+    // https://html.spec.whatwg.org/multipage/#dom-navigator-javaenabled
+    fn JavaEnabled(&self) -> bool {
+        false
+    }
 }
new file mode 100644
--- /dev/null
+++ b/servo/components/script/dom/plugin.rs
@@ -0,0 +1,61 @@
+/* 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 dom::bindings::codegen::Bindings::PluginBinding::PluginMethods;
+use dom::bindings::js::Root;
+use dom::bindings::reflector::{Reflector};
+use dom::mimetype::MimeType;
+use util::str::DOMString;
+
+#[dom_struct]
+pub struct Plugin {
+    reflector_: Reflector,
+}
+
+impl PluginMethods for Plugin {
+    // https://html.spec.whatwg.org/multipage/#dom-plugin-name
+    fn Name(&self) -> DOMString {
+        unreachable!()
+    }
+
+    // https://html.spec.whatwg.org/multipage/#dom-plugin-description
+    fn Description(&self) -> DOMString {
+        unreachable!()
+    }
+
+    // https://html.spec.whatwg.org/multipage/#dom-plugin-filename
+    fn Filename(&self) -> DOMString {
+        unreachable!()
+    }
+
+    // https://html.spec.whatwg.org/multipage/#dom-plugin-length
+    fn Length(&self) -> u32 {
+        unreachable!()
+    }
+
+    // https://html.spec.whatwg.org/multipage/#dom-plugin-item
+    fn Item(&self, _index: u32) -> Option<Root<MimeType>> {
+        unreachable!()
+    }
+
+    // https://html.spec.whatwg.org/multipage/#dom-plugin-nameditem
+    fn NamedItem(&self, _name: DOMString) -> Option<Root<MimeType>> {
+        unreachable!()
+    }
+
+    // https://html.spec.whatwg.org/multipage/#dom-plugin-item
+    fn IndexedGetter(&self, _index: u32, _found: &mut bool) -> Option<Root<MimeType>> {
+        unreachable!()
+    }
+
+    // check-tidy: no specs after this line
+    fn NamedGetter(&self, _name: DOMString, _found: &mut bool) -> Option<Root<MimeType>> {
+        unreachable!()
+    }
+
+    // https://heycam.github.io/webidl/#dfn-supported-property-names
+    fn SupportedPropertyNames(&self) -> Vec<DOMString> {
+        unreachable!()
+    }
+}
new file mode 100644
--- /dev/null
+++ b/servo/components/script/dom/pluginarray.rs
@@ -0,0 +1,67 @@
+/* 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 dom::bindings::codegen::Bindings::PluginArrayBinding;
+use dom::bindings::codegen::Bindings::PluginArrayBinding::PluginArrayMethods;
+use dom::bindings::global::GlobalRef;
+use dom::bindings::js::Root;
+use dom::bindings::reflector::{Reflector, reflect_dom_object};
+use dom::plugin::Plugin;
+use util::str::DOMString;
+
+#[dom_struct]
+pub struct PluginArray {
+    reflector_: Reflector,
+}
+
+impl PluginArray {
+    pub fn new_inherited() -> PluginArray {
+        PluginArray {
+            reflector_: Reflector::new()
+        }
+    }
+
+    pub fn new(global: GlobalRef) -> Root<PluginArray> {
+        reflect_dom_object(box PluginArray::new_inherited(),
+                           global,
+                           PluginArrayBinding::Wrap)
+    }
+}
+
+impl PluginArrayMethods for PluginArray {
+    // https://html.spec.whatwg.org/multipage/#dom-pluginarray-refresh
+    fn Refresh(&self, _reload: bool) {
+
+    }
+
+    // https://html.spec.whatwg.org/multipage/#dom-pluginarray-length
+    fn Length(&self) -> u32 {
+        0
+    }
+
+    // https://html.spec.whatwg.org/multipage/#dom-pluginarray-item
+    fn Item(&self, _index: u32) -> Option<Root<Plugin>> {
+        None
+    }
+
+    // https://html.spec.whatwg.org/multipage/#dom-pluginarray-nameditem
+    fn NamedItem(&self, _name: DOMString) -> Option<Root<Plugin>> {
+        None
+    }
+
+    // https://html.spec.whatwg.org/multipage/#dom-pluginarray-item
+    fn IndexedGetter(&self, _index: u32, _found: &mut bool) -> Option<Root<Plugin>> {
+        None
+    }
+
+    // check-tidy: no specs after this line
+    fn NamedGetter(&self, _name: DOMString, _found: &mut bool) -> Option<Root<Plugin>> {
+        None
+    }
+
+    // https://heycam.github.io/webidl/#dfn-supported-property-names
+    fn SupportedPropertyNames(&self) -> Vec<DOMString> {
+        vec![]
+    }
+}
new file mode 100644
--- /dev/null
+++ b/servo/components/script/dom/webidls/MimeType.webidl
@@ -0,0 +1,12 @@
+/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* 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/. */
+
+// https://html.spec.whatwg.org/multipage/#mimetype
+interface MimeType {
+  readonly attribute DOMString type;
+  readonly attribute DOMString description;
+  readonly attribute DOMString suffixes; // comma-separated
+  readonly attribute Plugin enabledPlugin;
+};
new file mode 100644
--- /dev/null
+++ b/servo/components/script/dom/webidls/MimeTypeArray.webidl
@@ -0,0 +1,12 @@
+/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* 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/. */
+
+// https://html.spec.whatwg.org/multipage/#mimetypearray
+[LegacyUnenumerableNamedProperties]
+interface MimeTypeArray {
+  readonly attribute unsigned long length;
+  getter MimeType? item(unsigned long index);
+  getter MimeType? namedItem(DOMString name);
+};
--- a/servo/components/script/dom/webidls/Navigator.webidl
+++ b/servo/components/script/dom/webidls/Navigator.webidl
@@ -8,17 +8,17 @@ interface Navigator {
   // objects implementing this interface also implement the interfaces given below
 };
 Navigator implements NavigatorID;
 Navigator implements NavigatorBluetooth;
 Navigator implements NavigatorLanguage;
 //Navigator implements NavigatorOnLine;
 //Navigator implements NavigatorContentUtils;
 //Navigator implements NavigatorStorageUtils;
-//Navigator implements NavigatorPlugins;
+Navigator implements NavigatorPlugins;
 
 // https://html.spec.whatwg.org/multipage/#navigatorid
 [NoInterfaceObject/*, Exposed=Window,Worker*/]
 interface NavigatorID {
   readonly attribute DOMString appCodeName; // constant "Mozilla"
   readonly attribute DOMString appName;
   readonly attribute DOMString appVersion;
   readonly attribute DOMString platform;
@@ -34,8 +34,16 @@ interface NavigatorBluetooth {
 
 // https://html.spec.whatwg.org/multipage/#navigatorlanguage
 [NoInterfaceObject/*, Exposed=Window,Worker*/]
 interface NavigatorLanguage {
   readonly attribute DOMString language;
   // https://github.com/servo/servo/issues/10073
   //readonly attribute DOMString[] languages;
 };
+
+// https://html.spec.whatwg.org/multipage/#navigatorplugins
+[NoInterfaceObject]
+interface NavigatorPlugins {
+  [SameObject] readonly attribute PluginArray plugins;
+  [SameObject] readonly attribute MimeTypeArray mimeTypes;
+  boolean javaEnabled();
+};
new file mode 100644
--- /dev/null
+++ b/servo/components/script/dom/webidls/Plugin.webidl
@@ -0,0 +1,15 @@
+/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* 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/. */
+
+// https://html.spec.whatwg.org/multipage/#dom-plugin
+[LegacyUnenumerableNamedProperties]
+interface Plugin {
+  readonly attribute DOMString name;
+  readonly attribute DOMString description;
+  readonly attribute DOMString filename;
+  readonly attribute unsigned long length;
+  getter MimeType? item(unsigned long index);
+  getter MimeType? namedItem(DOMString name);
+};
new file mode 100644
--- /dev/null
+++ b/servo/components/script/dom/webidls/PluginArray.webidl
@@ -0,0 +1,13 @@
+/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* 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/. */
+
+// https://html.spec.whatwg.org/multipage/#pluginarray
+[LegacyUnenumerableNamedProperties]
+interface PluginArray {
+  void refresh(optional boolean reload = false);
+  readonly attribute unsigned long length;
+  getter Plugin? item(unsigned long index);
+  getter Plugin? namedItem(DOMString name);
+};