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

Unified Diff: third_party/WebKit/LayoutTests/fast/dom/shadow/event-scoped-user-setting-on-creation.html

Issue 1586563005: Add Event.scoped (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/fast/dom/shadow/event-scoped-user-setting-on-creation.html
diff --git a/third_party/WebKit/LayoutTests/fast/dom/shadow/event-scoped-user-setting-on-creation.html b/third_party/WebKit/LayoutTests/fast/dom/shadow/event-scoped-user-setting-on-creation.html
new file mode 100644
index 0000000000000000000000000000000000000000..6ef0f3c05243c0d95f9985d8f3b81ee62a558dc3
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/fast/dom/shadow/event-scoped-user-setting-on-creation.html
@@ -0,0 +1,73 @@
+<!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) {
hayato 2016/01/15 03:59:52 Nit: Remove a space between "function" and "(e)".
yuzuchan 2016/01/15 05:32:27 Done.
+ test(function () {
hayato 2016/01/15 03:59:52 Nit: "function ()" => "function()"
yuzuchan 2016/01/15 05:32:27 Done.
+ assert_equals(e.scoped, true);
+ }, "UA load event's scoped should be set to true");
+};
+
+var resultTrusted = [];
+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);
+ }
+}
+var eventCount = 0;
+function recordEvent(event)
+{
+ if (event.type == 'load'){
hayato 2016/01/15 03:59:52 Nit. One space is required. between ")" and "{"
yuzuchan 2016/01/15 05:32:27 Done.
yuzuchan 2016/01/15 05:32:27 Done.
yuzuchan 2016/01/15 05:32:27 Done.
+ if(event.currentTarget){
hayato 2016/01/15 03:59:52 I guess event.currentTarget is always non-null. Ca
hayato 2016/01/15 03:59:52 Ditto. One space is required. ") {"
yuzuchan 2016/01/15 05:32:27 Done.
yuzuchan 2016/01/15 05:32:27 Done.
+ resultTrusted.push(event.currentTarget.id);
+ }
+ }else if (event.type == 'error'){
hayato 2016/01/15 03:59:52 Ditto: - "} else if" - ") {"
yuzuchan 2016/01/15 05:32:27 Done.
+ if(event.currentTarget){
+ resultNonTrusted.push(event.currentTarget.id);
+ }
+ }
+ eventCount++;
+ if (eventCount == 3) {
hayato 2016/01/15 03:59:52 This is assuming that "load" event happens before
yuzuchan 2016/01/15 05:32:27 Very true. Fixed in Patch 3. Done. On 2016/01/15
+ test(function () {
hayato 2016/01/15 03:59:52 Nit: "function ()" => "function()"
yuzuchan 2016/01/15 05:32:27 Done.
+ assert_array_equals(resultTrusted,['target']);
hayato 2016/01/15 03:59:52 Nit: One space is required after ","
yuzuchan 2016/01/15 05:32:27 Done.
+ assert_array_equals(resultNonTrusted, ['target', 'host']);
+ }, "Only certain trusted events like load should stop in bubbling.");
+ done();
+ }
+}
+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>
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/events/Event.h » ('j') | third_party/WebKit/Source/core/events/Event.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698