Bug 1461742, test for getCustomInterfaceCallback, r=bgrins
authorNeil Deakin <neil@mozilla.com>
Thu, 19 Jul 2018 09:32:18 -0400
changeset 427273 ca12371f08ac
parent 427272 19cb7b9936ee
child 427274 6b7ad73f1f43
push id105432
push userneil@mozilla.com
push dateThu, 19 Jul 2018 13:33:05 +0000
treeherdermozilla-inbound@ca12371f08ac [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbgrins
bugs1461742
milestone63.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1461742, test for getCustomInterfaceCallback, r=bgrins
toolkit/content/tests/chrome/test_custom_element_base.xul
--- a/toolkit/content/tests/chrome/test_custom_element_base.xul
+++ b/toolkit/content/tests/chrome/test_custom_element_base.xul
@@ -7,24 +7,27 @@
   xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
 
   <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
   <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
 
   <!-- test results are displayed in the html:body -->
   <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
 
+  <simpleelement id="simple"/>
+
   <!-- test code goes here -->
   <script type="application/javascript"><![CDATA[
 
   SimpleTest.waitForExplicitFinish();
 
   function runTests() {
     ok(MozXULElement, "MozXULElement defined on the window");
     testParseXULToFragment();
+    testCustomInterface();
     SimpleTest.finish();
   }
 
   function testParseXULToFragment() {
     ok(MozXULElement.parseXULToFragment, "parseXULToFragment helper exists");
 
     let frag = MozXULElement.parseXULToFragment(`<deck id='foo' />`);
     ok(frag instanceof DocumentFragment);
@@ -34,12 +37,45 @@
     let deck = document.documentElement.lastChild;
     ok(deck instanceof MozXULElement, "instance of MozXULElement");
     ok(deck instanceof XULElement, "instance of XULElement");
     is(deck.id, "foo", "attribute set");
     is(deck.selectedIndex, "0", "Custom Element is property attached");
     deck.remove();
   }
 
+  function testCustomInterface() {
+    class SimpleElement extends MozXULElement {
+      get disabled() {
+        return false;
+      }
+
+      set disabled(val) {
+      }
+
+      get tabIndex() {
+        return 0;
+      }
+
+      set tabIndex(val) {
+      }
+    }
+
+    customElements.define("simpleelement", SimpleElement);
+    MozXULElement.implementCustomInterface(SimpleElement, [Ci.nsIDOMXULControlElement]);
+
+    is(document.documentElement.getCustomInterfaceCallback, undefined,
+       "No getCustomInterfaceCallback on non-custom element");
+    is(typeof document.getElementById("simple").getCustomInterfaceCallback, "function",
+       "getCustomInterfaceCallback available on custom element when set");
+    try {
+      document.documentElement.QueryInterface(Ci.nsIDOMXULControlElement)
+      ok(false, "Non-custom element implements custom interface");
+    } catch (ex) {
+      ok(true, "Non-custom element implements custom interface");
+    }
+    ok(document.getElementById("simple").QueryInterface(Ci.nsIDOMXULControlElement),
+       "Implements custom interface");
+  }
   ]]>
   </script>
 </window>