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

Unified Diff: third_party/WebKit/LayoutTests/shadow-dom/events-related-target-scoped.html

Issue 1817453002: Implement Event.relatedTargetScoped (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove unnecessary changes Created 4 years, 9 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/shadow-dom/events-related-target-scoped.html
diff --git a/third_party/WebKit/LayoutTests/shadow-dom/events-related-target-scoped.html b/third_party/WebKit/LayoutTests/shadow-dom/events-related-target-scoped.html
new file mode 100644
index 0000000000000000000000000000000000000000..d964d247feeeb7e652abfe5b4ca819360bf44d7d
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/shadow-dom/events-related-target-scoped.html
@@ -0,0 +1,110 @@
+<!DOCTYPE html>
+<script src="../resources/testharness.js"></script>
+<script src="../resources/testharnessreport.js"></script>
+<script src="../fast/dom/shadow/resources/shadow-dom.js"></script>
+
+<div id="log"></div>
+<div id="sandbox">
+ <div id = "host">
+ <template>
+ <input id="target1"></input>
+ <input id="target2"></input>
+ <input id="target3"></input>
+ <input id="target4"></input>
+ </template>
+ </div>
+</div>
+
+<script>
+
+function moveMouseOver(element)
+{
+ if (!window.eventSender || !window.internals)
+ return;
+
+ var defaultPaddingSize = 20;
+ var x = element.offsetLeft + element.offsetWidth / 2;
+ var y;
+ if (element.hasChildNodes() || window.internals.shadowRoot(element))
+ y = element.offsetTop + defaultPaddingSize;
+ else
+ y = element.offsetTop + element.offsetHeight / 2;
+ eventSender.mouseMoveTo(x, y);
+}
+
+var sandbox = document.getElementById('sandbox');
+convertTemplatesToShadowRootsWithin(sandbox);
+var target1 = getNodeInComposedTree('host/target1');
+var target2 = getNodeInComposedTree('host/target2');
+var target3 = getNodeInComposedTree('host/target3');
+var target4 = getNodeInComposedTree('host/target4');
+
+async_test(function(t) {
+ target1.onfocus = function(e) {
+ t.step(function() {
+ assert_equals(e.relatedTarget, null);
+ assert_false(e.relatedTargetScoped);
+ t.done();
+ });
+ };
+ target1.focus();
+}, 'Trusted events should have relatedTargetScoped set to false by default.');
+
+async_test(function(t) {
hayato 2016/03/18 06:26:52 It looks that this test is assuming that target1 i
yuzuchan 2016/03/18 07:20:15 Thanks for the comment, done.
+ target2.onfocus = function(e) {
+ t.step(function() {
+ assert_equals(e.relatedTarget, target1);
+ assert_true(e.relatedTargetScoped);
+ t.done();
+ });
+ };
+ target2.focus();
+}, 'Trusted focus events with a related target should have relatedTargetScoped true.');
+
+async_test(function(t) {
+ target1.onmouseenter = function(e) {
+ t.step(function() {
+ assert_equals(e.relatedTarget, null);
+ assert_false(e.relatedTargetScoped);
+ t.done();
+ });
+ };
+ moveMouseOver(target1);
+}, 'Trusted mouse events without a related target should have relatedTargetScoped set to false.');
+
+async_test(function(t) {
+ target2.onmouseenter = function(e) {
+ t.step(function() {
+ assert_equals(e.relatedTarget, target1);
+ assert_true(e.relatedTargetScoped);
+ t.done();
+ });
+ };
+ moveMouseOver(target2);
+}, 'Trusted mouse events with a related target should have relatedTargetScoped true.');
+
+async_test(function(t) {
+ var userFocus1 = new FocusEvent('focus', { relatedTarget: target4 });
+ target3.onfocus = function(e) {
+ t.step(function() {
+ assert_equals(e.relatedTarget, target4);
+ assert_false(e.relatedTargetScoped);
+ t.done();
+ });
+ };
+ target3.dispatchEvent(userFocus1);
+}, 'Untrusted events should have relatedTargetScoped set to false by default.');
+
+async_test(function(t) {
+ var userFocus2 = new FocusEvent('focus', { relatedTarget: target3, relatedTargetScoped: true });
+ target4.onfocus = function(e) {
+ t.step(function() {
+ assert_equals(e.relatedTarget, target3);
+ assert_true(e.relatedTargetScoped);
+ t.done();
+ });
+ };
+ target4.dispatchEvent(userFocus2);
+}, 'Trusted focus events with a related target should have relatedTargetScoped true.');
+
+</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.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698