Bug 1577592 - Test case for Shadow Parts not applying with fragment containing XUL element r=emilio
authorBrian Grinstead <bgrinstead@mozilla.com>
Thu, 29 Aug 2019 22:28:23 +0000
changeset 554592 a334d3b33b26f99947e93c6264aaab6632497156
parent 554591 b78fd9e42adcaeac7548f5a999630b5c75d5c039
child 554593 c9a04ff4a68a1848cce52923b2c9244f438ab541
push id2165
push userffxbld-merge
push dateMon, 14 Oct 2019 16:30:58 +0000
treeherdermozilla-release@0eae18af659f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersemilio
bugs1577592
milestone70.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 1577592 - Test case for Shadow Parts not applying with fragment containing XUL element r=emilio Differential Revision: https://phabricator.services.mozilla.com/D44034
toolkit/content/tests/chrome/chrome.ini
toolkit/content/tests/chrome/test_custom_element_parts.html
--- a/toolkit/content/tests/chrome/chrome.ini
+++ b/toolkit/content/tests/chrome/chrome.ini
@@ -99,16 +99,17 @@ support-files = bug451540_window.xul
 [test_bug792324.xul]
 [test_bug1048178.xul]
 skip-if = toolkit == "cocoa"
 [test_button.xul]
 [test_closemenu_attribute.xul]
 [test_contextmenu_list.xul]
 [test_custom_element_base.xul]
 [test_custom_element_delay_connection.xul]
+[test_custom_element_parts.html]
 [test_deck.xul]
 [test_dialogfocus.xul]
 [test_edit_contextmenu.html]
 [test_editor_for_input_with_autocomplete.html]
 [test_editor_for_textbox_with_autocomplete.xul]
 [test_findbar.xul]
 tags = clipboard
 skip-if = os == 'mac' && os_version == '10.14' # macosx1014 due to 1550078
new file mode 100644
--- /dev/null
+++ b/toolkit/content/tests/chrome/test_custom_element_parts.html
@@ -0,0 +1,44 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+  <meta charset="utf-8">
+  <title><!-- Shadow Parts issue with xul/xbl domparser --></title>
+  <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+  <link rel="stylesheet" href="chrome://mochikit/content/tests/SimpleTest/test.css"/>
+  <style>custom-button::part(foo) { background: red; }</style>
+  <script>
+    add_task(async function test() {
+      // A simplified version of what MozXULElement.parseXULToFragment does
+      let parser = new DOMParser();
+      parser.forceEnableXULXBL();
+      let doc = parser.parseFromString(`<box xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"><box part="foo">there</box></box>`, `application/xml`);
+      let range = doc.createRange();
+      range.selectNodeContents(doc.querySelector("box"));
+      let frag = range.extractContents();
+
+      customElements.define("custom-button", class extends HTMLElement {
+        constructor() {
+          super();
+          this.attachShadow({mode: "open"});
+          this.shadowRoot.appendChild(document.importNode(frag, true));
+        }
+      });
+      let button = document.createElement("custom-button");
+      document.body.appendChild(button);
+
+      let box = button.shadowRoot.querySelector("box");
+
+      // XXX: this fixes it
+      // box.removeAttribute("part");
+      // box.setAttribute("part", "foo");
+
+      is(window.getComputedStyle(box).getPropertyValue("background-color"), "rgb(255, 0, 0)", "part applied");
+    });
+  </script>
+</head>
+<body>
+<p id="display"></p>
+<div id="content" style="display: none"></div>
+<pre id="test"></pre>
+</body>
+</html>