Bug 1594122 - convert XBL test test_bug330925.xhtml to shadow DOM test r=bzbarsky
authorAlexander Surkov <surkov.alexander@gmail.com>
Fri, 08 Nov 2019 18:40:40 +0000
changeset 501352 8823aa7d4ff9ea4ea54da4b453fdd17ddefb3b5c
parent 501351 44afbc73fe15710fcc9d1591d8a783a55473cb04
child 501353 aba92aad986e96b08f23ffd7a20a0d672efd2945
push id114168
push userdluca@mozilla.com
push dateSun, 10 Nov 2019 03:08:55 +0000
treeherdermozilla-inbound@33f64c1ef3e4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbzbarsky
bugs1594122, 330925
milestone72.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 1594122 - convert XBL test test_bug330925.xhtml to shadow DOM test r=bzbarsky Differential Revision: https://phabricator.services.mozilla.com/D52209
dom/base/test/mochitest.ini
dom/base/test/test_bug330925.html
dom/base/test/test_bug330925.xhtml
--- a/dom/base/test/mochitest.ini
+++ b/dom/base/test/mochitest.ini
@@ -307,18 +307,17 @@ skip-if = headless # headless != clipboa
 [test_bug282547.html]
 [test_bug298064.html]
 [test_bug300992.html]
 [test_bug311681.xml]
 [test_bug313646.html]
 [test_bug320799.html]
 [test_bug322317.html]
 [test_bug326337.html]
-[test_bug330925.xhtml]
-skip-if = !xbl
+[test_bug330925.html]
 [test_bug331959.html]
 [test_bug333064.html]
 skip-if = headless # Headless: Bug 1405868
 [test_bug333198.html]
 [test_bug333673.html]
 [test_bug337631.html]
 [test_bug338541.xhtml]
 [test_bug338583.html]
rename from dom/base/test/test_bug330925.xhtml
rename to dom/base/test/test_bug330925.html
--- a/dom/base/test/test_bug330925.xhtml
+++ b/dom/base/test/test_bug330925.html
@@ -1,74 +1,58 @@
-<html xmlns="http://www.w3.org/1999/xhtml">
+<html>
 <!--
 https://bugzilla.mozilla.org/show_bug.cgi?id=330925
 -->
 <head>
   <title>Test for Bug 330925</title>
   <script src="/tests/SimpleTest/SimpleTest.js"></script>
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
 
-<style type="text/css">
-#t {
--moz-binding: url(#randomxbl);
-}
-</style>
-
-<bindings xmlns="http://www.mozilla.org/xbl">
-<binding id="randomxbl" inheritstyle="false">
-<content>
-xbl textnode1
-<div>
-xbl textnode2
-<children xmlns="http://www.mozilla.org/xbl"/>
-</div>
-</content>
-</binding>
-</bindings>
-
 </head>
 <body>
 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=330925">Mozilla Bug 330925</a>
 
 <p id="display">
-<div id="t" />
+<el-custom id="t"></el-custom>
 </p>
 
 <pre id="test">
 <script class="testbody" type="text/javascript">
-<![CDATA[
-
-/** Test for Bug 330925 **/
+customElements.define("el-custom", class extends HTMLElement {
+  constructor() {
+    super();
+    this.attachShadow({ mode: "open" });
+    this.shadowRoot.innerHTML = `
+xbl textnode1
+<div>
+xbl textnode2
+<slot></slot>
+</div>
+    `;
+  }
+});
 
-// We have to wait until onload because XBL doesn't bind immediately.
-SimpleTest.waitForExplicitFinish();
-addLoadEvent(init);
-
-function init()
-{
-  var t = document.getElementById("t");
-  var d = SpecialPowers.wrap(document);
+let t = document.getElementById("t");
+let d = SpecialPowers.wrap(document);
 
-  is(SpecialPowers.unwrap(d.getBindingParent(d.getAnonymousNodes(t)[0])),
-     t,
-     "Wrong binding parent for anonymous node");
-     
-  is(SpecialPowers.unwrap(d.getBindingParent(d.getAnonymousNodes(t)[1].childNodes[0])),
-     t,
-     "Wrong binding parent for child of anonymous node");
-     
-  is(d.getBindingParent(t), 
-     null,
-     "Non-anonymous node should not have a binding parent");
-     
-  is(d.getBindingParent(document.documentElement), 
-     null,
-     "Document element should not have a binding parent");
-     
-  SimpleTest.finish();
-}
+let tn1 = t.shadowRoot.firstChild;
+let tn2 = t.shadowRoot.firstChild.nextSibling.firstChild;
+
+is(SpecialPowers.unwrap(d.getBindingParent(tn1)),
+   t,
+   "Wrong binding parent for shadow DOM node");
 
-]]>
+is(SpecialPowers.unwrap(d.getBindingParent(tn2)),
+   t,
+   "Wrong binding parent for child of shadow DOM node");
+
+is(d.getBindingParent(t),
+   null,
+   "Non shadow DOM node should not have a binding parent");
+
+is(d.getBindingParent(document.documentElement),
+   null,
+   "Document element should not have a binding parent");
 </script>
 </pre>
 </body>
 </html>