Title: [238692] trunk/LayoutTests/imported/w3c
Revision
238692
Author
[email protected]
Date
2018-11-29 13:26:28 -0800 (Thu, 29 Nov 2018)

Log Message

Update web-platform-tests/shadow-dom
https://bugs.webkit.org/show_bug.cgi?id=192137

Reviewed by Antti Koivisto.

Re-imported the shadow DOM tests from wpt.

* resources/import-expectations.json:
* web-platform-tests/shadow-dom/ShadowRoot-interface.html:
* web-platform-tests/shadow-dom/event-dispatch-order.tentative-expected.txt: Added.
* web-platform-tests/shadow-dom/event-dispatch-order.tentative.html: Added.
* web-platform-tests/shadow-dom/input-type-radio-expected.txt: Added.
* web-platform-tests/shadow-dom/input-type-radio.html: Added.
* web-platform-tests/shadow-dom/resources/shadow-dom.js:
(dispatchEventWithLog):
(assert_event_path_equals):
* web-platform-tests/shadow-dom/slots-outside-shadow-dom-expected.txt: Added.
* web-platform-tests/shadow-dom/slots-outside-shadow-dom.html: Added.
* web-platform-tests/shadow-dom/w3c-import.log:

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (238691 => 238692)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2018-11-29 21:25:29 UTC (rev 238691)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2018-11-29 21:26:28 UTC (rev 238692)
@@ -1,3 +1,25 @@
+2018-11-28  Ryosuke Niwa  <[email protected]>
+
+        Update web-platform-tests/shadow-dom
+        https://bugs.webkit.org/show_bug.cgi?id=192137
+
+        Reviewed by Antti Koivisto.
+
+        Re-imported the shadow DOM tests from wpt.
+
+        * resources/import-expectations.json:
+        * web-platform-tests/shadow-dom/ShadowRoot-interface.html:
+        * web-platform-tests/shadow-dom/event-dispatch-order.tentative-expected.txt: Added.
+        * web-platform-tests/shadow-dom/event-dispatch-order.tentative.html: Added.
+        * web-platform-tests/shadow-dom/input-type-radio-expected.txt: Added.
+        * web-platform-tests/shadow-dom/input-type-radio.html: Added.
+        * web-platform-tests/shadow-dom/resources/shadow-dom.js:
+        (dispatchEventWithLog):
+        (assert_event_path_equals):
+        * web-platform-tests/shadow-dom/slots-outside-shadow-dom-expected.txt: Added.
+        * web-platform-tests/shadow-dom/slots-outside-shadow-dom.html: Added.
+        * web-platform-tests/shadow-dom/w3c-import.log:
+
 2018-11-29  Youenn Fablet  <[email protected]>
 
         Updating a service worker during a navigation load sometimes makes the load fail

Modified: trunk/LayoutTests/imported/w3c/resources/import-expectations.json (238691 => 238692)


--- trunk/LayoutTests/imported/w3c/resources/import-expectations.json	2018-11-29 21:25:29 UTC (rev 238691)
+++ trunk/LayoutTests/imported/w3c/resources/import-expectations.json	2018-11-29 21:26:28 UTC (rev 238692)
@@ -354,4 +354,4 @@
     "web-platform-tests/worklets": "skip", 
     "web-platform-tests/x-frame-options": "skip", 
     "web-platform-tests/xhr": "import"
-}
+}
\ No newline at end of file

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/ShadowRoot-interface.html (238691 => 238692)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/ShadowRoot-interface.html	2018-11-29 21:25:29 UTC (rev 238691)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/ShadowRoot-interface.html	2018-11-29 21:26:28 UTC (rev 238692)
@@ -94,8 +94,10 @@
         var host = document.createElement('div');
         var shadowRoot = host.attachShadow({'mode': mode});
 
-        assert_equals(shadowRoot.styleSheets.length, 0, 'shadowRoot.styleSheets must be empty when the shadow root does not contain any stylesheets');
         shadowRoot.innerHTML = '<span></span><style> a.rule {} </style><style> b.rule {} </style>';
+        assert_equals(shadowRoot.styleSheets.length, 0, 'shadowRoot.styleSheets must be empty when the shadow root is not connected');
+
+        document.body.appendChild(host);
         assert_equals(shadowRoot.styleSheets.length, 2, 'shadowRoot.styleSheets must contain two items when the shadow root has two style elements');
         var styles = shadowRoot.querySelectorAll('style');
         assert_equals(shadowRoot.styleSheets[0], styles[0].sheet, 'shadowRoot.styleSheets[0] must be the first style element in the shadow root');

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/event-dispatch-order.tentative-expected.txt (0 => 238692)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/event-dispatch-order.tentative-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/event-dispatch-order.tentative-expected.txt	2018-11-29 21:26:28 UTC (rev 238692)
@@ -0,0 +1,3 @@
+
+PASS Event dispatch order: capture listerns should be called in capturing phase at a shadow host 
+

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/event-dispatch-order.tentative.html (0 => 238692)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/event-dispatch-order.tentative.html	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/event-dispatch-order.tentative.html	2018-11-29 21:26:28 UTC (rev 238692)
@@ -0,0 +1,30 @@
+<!DOCTYPE html>
+<title>Shadow DOM: event dispatch order for capture and non-capture listerns at a shadow host</title>
+<meta name="author" title="Hayato Ito" href=""
+<link rel="help" href=""
+<link rel="help" href=""
+<script src=""
+<script src=""
+<script src=""
+<div id=host>
+  <template id=shadowroot data-mode=open>
+    <div id=target></div>
+  </template>
+</div>
+<script>
+test(() => {
+  let nodes = createTestTree(host);
+  let log = dispatchEventWithLog(nodes, nodes.target,
+                                 new Event('my-event', { bubbles: true, composed: true }),
+                                 { capture: true });
+  let path = ['target', 'shadowroot', 'host'];
+  assert_event_path_equals(log,
+                           [['host', 'host', null, path, 'capture'],
+                            ['shadowroot', 'target', null, path, 'capture'],
+                            ['target', 'target', null, path, 'capture'],
+                            ['target', 'target', null, path, 'non-capture'],
+                            ['shadowroot', 'target', null, path, 'non-capture'],
+                            ['host', 'host', null, path, 'non-capture'],
+                           ]);
+}, 'Event dispatch order: capture listerns should be called in capturing phase at a shadow host');
+</script>

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/input-type-radio-expected.txt (0 => 238692)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/input-type-radio-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/input-type-radio-expected.txt	2018-11-29 21:26:28 UTC (rev 238692)
@@ -0,0 +1,4 @@
+ 
+
+FAIL input type=radio elements should form a group inside shadow DOM. assert_true: expected true got false
+

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/input-type-radio.html (0 => 238692)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/input-type-radio.html	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/input-type-radio.html	2018-11-29 21:26:28 UTC (rev 238692)
@@ -0,0 +1,73 @@
+<!doctype html>
+<meta charset=utf-8>
+<title></title>
+<script src=""
+<script src=""
+<input type="radio" name="group" id="lightRadio1">
+<input type="radio" name="group" id="lightRadio2">
+<div id="host"></div>
+<script>
+
+test(() => {
+    var lightRadio1 = document.getElementById("lightRadio1");
+    var lightRadio2 = document.getElementById("lightRadio2");
+
+    var host = document.getElementById("host");
+    var sr = host.attachShadow({mode: "closed"});
+    var shadowRadio1 = document.createElement("input");
+    shadowRadio1.name = "group";
+    shadowRadio1.id = "shadowRadio1";
+    shadowRadio1.type = "radio";
+    sr.appendChild(shadowRadio1);
+    var shadowRadio2 = document.createElement("input");
+    shadowRadio2.name = "group";
+    shadowRadio2.id = "shadowRadio2";
+    shadowRadio2.type = "radio";
+    sr.appendChild(shadowRadio2);
+
+    assert_false(lightRadio1.checked);
+    assert_false(lightRadio2.checked);
+    assert_false(shadowRadio1.checked);
+    assert_false(shadowRadio2.checked);
+
+    lightRadio1.click();
+    assert_true(lightRadio1.checked);
+    assert_false(lightRadio2.checked);
+    assert_false(shadowRadio1.checked);
+    assert_false(shadowRadio2.checked);
+
+    lightRadio2.click();
+    assert_false(lightRadio1.checked);
+    assert_true(lightRadio2.checked);
+    assert_false(shadowRadio1.checked);
+    assert_false(shadowRadio2.checked);
+
+    shadowRadio1.click();
+    assert_false(lightRadio1.checked);
+    assert_true(lightRadio2.checked);
+    assert_true(shadowRadio1.checked);
+    assert_false(shadowRadio2.checked);
+
+    shadowRadio2.click();
+    assert_false(lightRadio1.checked);
+    assert_true(lightRadio2.checked);
+    assert_false(shadowRadio1.checked);
+    assert_true(shadowRadio2.checked);
+
+    // Ensure radio groups work even when modifying shadow DOM.
+    shadowRadio2.remove();
+    sr.appendChild(shadowRadio2);
+    shadowRadio2.click();
+    assert_false(lightRadio1.checked);
+    assert_true(lightRadio2.checked);
+    assert_false(shadowRadio1.checked);
+    assert_true(shadowRadio2.checked);
+
+    shadowRadio1.click();
+    assert_false(lightRadio1.checked);
+    assert_true(lightRadio2.checked);
+    assert_true(shadowRadio1.checked);
+    assert_false(shadowRadio2.checked);
+}, "input type=radio elements should form a group inside shadow DOM.");
+
+</script>

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/resources/shadow-dom.js (238691 => 238692)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/resources/shadow-dom.js	2018-11-29 21:25:29 UTC (rev 238691)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/resources/shadow-dom.js	2018-11-29 21:26:28 UTC (rev 238692)
@@ -53,7 +53,9 @@
   return ids;
 }
 
-function dispatchEventWithLog(nodes, target, event) {
+// TODO: Refactor this so that only interested results are recorded.
+// Callers of this function would not be interested in every results.
+function dispatchEventWithLog(nodes, target, event, options) {
 
   function labelFor(e) {
     return e.id || e.tagName;
@@ -70,15 +72,40 @@
       if (!id)
         continue;
       attachedNodes.push(node);
-      node.addEventListener(event.type, (e) => {
+      if (options && options.capture) {
+        // Record [currentTarget, target, relatedTarget, composedPath(), 'capture' | 'non-capture']
+        // TODO: Support registering listeners in different orders.
+        // e.g. Register a non-capture listener at first, then register a capture listener.
+        node.addEventListener(event.type, (e) => {
+          log.push([id,
+                    labelFor(e.target),
+                    e.relatedTarget ? labelFor(e.relatedTarget) : null,
+                    e.composedPath().map((n) => {
+                      return labelFor(n);
+                    }),
+                    'capture']);
+        }, true);
+        node.addEventListener(event.type, (e) => {
+          log.push([id,
+                    labelFor(e.target),
+                    e.relatedTarget ? labelFor(e.relatedTarget) : null,
+                    e.composedPath().map((n) => {
+                      return labelFor(n);
+                    }),
+                    'non-capture']);
+        });
+      } else {
         // Record [currentTarget, target, relatedTarget, composedPath()]
-        log.push([id,
-                  labelFor(e.target),
-                  e.relatedTarget ? labelFor(e.relatedTarget) : null,
-                  e.composedPath().map((n) => {
-                    return labelFor(n);
-                  })]);
-      });
+        node.addEventListener(event.type, (e) => {
+          log.push([id,
+                    labelFor(e.target),
+                    e.relatedTarget ? labelFor(e.relatedTarget) : null,
+                    e.composedPath().map((n) => {
+                      return labelFor(n);
+                    })]
+                  );
+        });
+      }
     }
   }
   target.dispatchEvent(event);
@@ -122,9 +149,13 @@
 function assert_event_path_equals(actual, expected) {
   assert_equals(actual.length, expected.length);
   for (let i = 0; i < actual.length; ++i) {
+    assert_equals(actual[i].length, expected[i].length);
     assert_equals(actual[i][0], expected[i][0], 'currentTarget at ' + i + ' should be same');
     assert_equals(actual[i][1], expected[i][1], 'target at ' + i + ' should be same');
     assert_equals(actual[i][2], expected[i][2], 'relatedTarget at ' + i + ' should be same');
     assert_array_equals(actual[i][3], expected[i][3], 'composedPath at ' + i + ' should be same');
+    if (actual[i][4]) {
+      assert_equals(actual[i][4], expected[i][4], 'listener type should be same at ' + i);
+    }
   }
 }

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/slots-outside-shadow-dom-expected.txt (0 => 238692)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/slots-outside-shadow-dom-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/slots-outside-shadow-dom-expected.txt	2018-11-29 21:26:28 UTC (rev 238692)
@@ -0,0 +1,4 @@
+foo
+
+FAIL Light DOM slot element should be in flattened assignedNodes assert_array_equals: property 0, expected Element node <slot>foo</slot> but got Text node "foo"
+

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/slots-outside-shadow-dom.html (0 => 238692)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/slots-outside-shadow-dom.html	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/slots-outside-shadow-dom.html	2018-11-29 21:26:28 UTC (rev 238692)
@@ -0,0 +1,16 @@
+<!doctype html>
+<meta charset=utf-8>
+<title></title>
+<script src=""
+<script src=""
+<div id="host1"><slot>foo</slot></div>
+<script>
+
+test(() => {
+  var host1 = document.getElementById("host1");
+  var sr = host1.attachShadow({mode: "open"});
+  sr.innerHTML = "<slot></slot>";
+  assert_array_equals(sr.firstChild.assignedNodes({ flatten: true }), [host1.firstChild]);
+}, "Light DOM slot element should be in flattened assignedNodes");
+
+</script>

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/w3c-import.log (238691 => 238692)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/w3c-import.log	2018-11-29 21:25:29 UTC (rev 238691)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/w3c-import.log	2018-11-29 21:26:28 UTC (rev 238692)
@@ -35,6 +35,7 @@
 /LayoutTests/imported/w3c/web-platform-tests/shadow-dom/event-composed-path-with-related-target.html
 /LayoutTests/imported/w3c/web-platform-tests/shadow-dom/event-composed-path.html
 /LayoutTests/imported/w3c/web-platform-tests/shadow-dom/event-composed.html
+/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/event-dispatch-order.tentative.html
 /LayoutTests/imported/w3c/web-platform-tests/shadow-dom/event-inside-shadow-tree.html
 /LayoutTests/imported/w3c/web-platform-tests/shadow-dom/event-inside-slotted-node.html
 /LayoutTests/imported/w3c/web-platform-tests/shadow-dom/event-post-dispatch.html
@@ -43,6 +44,7 @@
 /LayoutTests/imported/w3c/web-platform-tests/shadow-dom/getElementById-dynamic-001.html
 /LayoutTests/imported/w3c/web-platform-tests/shadow-dom/historical.html
 /LayoutTests/imported/w3c/web-platform-tests/shadow-dom/input-element-list.html
+/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/input-type-radio.html
 /LayoutTests/imported/w3c/web-platform-tests/shadow-dom/layout-slot-no-longer-assigned-expected.html
 /LayoutTests/imported/w3c/web-platform-tests/shadow-dom/layout-slot-no-longer-assigned.html
 /LayoutTests/imported/w3c/web-platform-tests/shadow-dom/layout-slot-no-longer-fallback-expected.html
@@ -53,4 +55,5 @@
 /LayoutTests/imported/w3c/web-platform-tests/shadow-dom/slotchange.html
 /LayoutTests/imported/w3c/web-platform-tests/shadow-dom/slots-fallback-in-document.html
 /LayoutTests/imported/w3c/web-platform-tests/shadow-dom/slots-fallback.html
+/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/slots-outside-shadow-dom.html
 /LayoutTests/imported/w3c/web-platform-tests/shadow-dom/slots.html
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to