Index: third_party/WebKit/LayoutTests/fast/dom/shadow/scoped-events-by-ua-stopped.html |
diff --git a/third_party/WebKit/LayoutTests/fast/dom/shadow/scoped-events-by-ua-stopped.html b/third_party/WebKit/LayoutTests/fast/dom/shadow/scoped-events-by-ua-stopped.html |
new file mode 100644 |
index 0000000000000000000000000000000000000000..a06786ced5b1d9d0a62829c87405851c346232f8 |
--- /dev/null |
+++ b/third_party/WebKit/LayoutTests/fast/dom/shadow/scoped-events-by-ua-stopped.html |
@@ -0,0 +1,76 @@ |
+<!DOCTYPE html> |
+<script src="../../../resources/testharness.js"></script> |
+<script src="../../../resources/testharnessreport.js"></script> |
+<script src="resources/shadow-dom.js"></script> |
+<img id="img" src="../../images/resources/test-load.jpg"> |
+<div id="sandbox"> |
+ <div id = "host"> |
+ <template> |
+ <img id="target" src="../../images/resources/test-load.jpg"> |
+ </template> |
+ </div> |
+</div> |
+<script> |
+setup({ explicit_done: true }); |
+var e; |
+test(function() { |
+ e = new Event('test'); |
+ assert_equals(e.scoped, false); |
+}, "A new event's scoped value should be set to false by default."); |
+ |
+test(function() { |
+ e = new Event('test', { scoped: true }); |
+ assert_equals(e.scoped, true); |
+}, 'Users should be able to set a scoped value.'); |
+ |
+img.onload = function(e) { |
+ test(function() { |
+ assert_equals(e.scoped, true); |
kochi
2016/01/27 06:02:16
Can you guarantee that onload event ever happens i
|
+ }, "UA load event's scoped should be set to true"); |
+}; |
+ |
+var resultNonTrusted = []; |
+ |
+function addEventListeners(nodes) |
+{ |
+ for (var i = 0; i < nodes.length; ++i) { |
+ var node = getNodeInTreeOfTrees(nodes[i]); |
+ node.addEventListener('load', recordEvent, false); |
+ node.addEventListener('error', recordEvent, false); |
+ } |
+} |
+ |
+function recordEvent(event) |
+{ |
+ if (event.type == 'load') { |
+ if (event.currentTarget.id == 'host'){ |
+ test(function() { |
+ assert_true(false); |
+ }, "Load event should be stopped if created by UAs."); |
+ } else { |
+ test(function() { |
+ assert_equals(event.currentTarget.id, 'target'); |
kochi
2016/01/27 06:02:16
The test above (assert_true(false) is okay in the
|
+ }, "Event fired in the right place."); |
+ } |
+ } |
+ if (event.type == 'error') { |
+ resultNonTrusted.push(event.currentTarget.id); |
kochi
2016/01/27 06:02:16
Why this 'error' event did not cause the same erro
|
+ if (resultNonTrusted.length == 2) { |
+ test(function() { |
+ assert_array_equals(resultNonTrusted, ['target', 'host']); |
+ }, "Only certain trusted events should stop in bubbling."); |
+ done(); |
kochi
2016/01/27 06:02:16
done() can only be used in async_test().
|
+ } |
+ } |
+} |
+ |
+var sandbox = document.getElementById('sandbox'); |
+convertTemplatesToShadowRootsWithin(sandbox); |
+var targetImg = getNodeInTreeOfTrees('host/target'); |
+addEventListeners(['host', 'host/target']); |
+ |
+targetImg.setAttribute('src', '../../images/resources/lenna.jpg'); |
+var userError = new Event('error'); |
+targetImg.dispatchEvent(userError); |
+ |
+</script> |