Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(376)

Side by Side Diff: third_party/WebKit/LayoutTests/fast/dom/shadow/scoped-events-by-ua-stopped.html

Issue 1586563005: Add Event.scoped (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove error from test case as it bubbles up and fails test\ Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <script src="../../../resources/testharness.js"></script>
3 <script src="../../../resources/testharnessreport.js"></script>
4 <script src="resources/shadow-dom.js"></script>
5 <img id="img" src="../../images/resources/test-load.jpg">
6 <div id="sandbox">
7 <div id = "host">
8 <template>
9 <img id="target" src="../../images/resources/test-load.jpg">
10 </template>
11 </div>
12 </div>
13 <script>
14 setup({ explicit_done: true });
15 var e;
16 test(function() {
17 e = new Event('test');
18 assert_equals(e.scoped, false);
19 }, "A new event's scoped value should be set to false by default.");
20
21 test(function() {
22 e = new Event('test', { scoped: true });
23 assert_equals(e.scoped, true);
24 }, 'Users should be able to set a scoped value.');
25
26 img.onload = function(e) {
27 test(function() {
28 assert_equals(e.scoped, true);
kochi 2016/01/27 06:02:16 Can you guarantee that onload event ever happens i
29 }, "UA load event's scoped should be set to true");
30 };
31
32 var resultNonTrusted = [];
33
34 function addEventListeners(nodes)
35 {
36 for (var i = 0; i < nodes.length; ++i) {
37 var node = getNodeInTreeOfTrees(nodes[i]);
38 node.addEventListener('load', recordEvent, false);
39 node.addEventListener('error', recordEvent, false);
40 }
41 }
42
43 function recordEvent(event)
44 {
45 if (event.type == 'load') {
46 if (event.currentTarget.id == 'host'){
47 test(function() {
48 assert_true(false);
49 }, "Load event should be stopped if created by UAs.");
50 } else {
51 test(function() {
52 assert_equals(event.currentTarget.id, 'target');
kochi 2016/01/27 06:02:16 The test above (assert_true(false) is okay in the
53 }, "Event fired in the right place.");
54 }
55 }
56 if (event.type == 'error') {
57 resultNonTrusted.push(event.currentTarget.id);
kochi 2016/01/27 06:02:16 Why this 'error' event did not cause the same erro
58 if (resultNonTrusted.length == 2) {
59 test(function() {
60 assert_array_equals(resultNonTrusted, ['target', 'host']);
61 }, "Only certain trusted events should stop in bubbling.");
62 done();
kochi 2016/01/27 06:02:16 done() can only be used in async_test().
63 }
64 }
65 }
66
67 var sandbox = document.getElementById('sandbox');
68 convertTemplatesToShadowRootsWithin(sandbox);
69 var targetImg = getNodeInTreeOfTrees('host/target');
70 addEventListeners(['host', 'host/target']);
71
72 targetImg.setAttribute('src', '../../images/resources/lenna.jpg');
73 var userError = new Event('error');
74 targetImg.dispatchEvent(userError);
75
76 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698