Index: third_party/WebKit/LayoutTests/imported/web-platform-tests/shadow-dom/untriaged/user-interaction/focus-navigation/test-002.html |
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/shadow-dom/untriaged/user-interaction/focus-navigation/test-002.html b/third_party/WebKit/LayoutTests/imported/web-platform-tests/shadow-dom/untriaged/user-interaction/focus-navigation/test-002.html |
index 151c0501e7d0b42212724a58375208abf1f814d5..aa325f57928abf7ed9aaf1d2698e332df8cca553 100644 |
--- a/third_party/WebKit/LayoutTests/imported/web-platform-tests/shadow-dom/untriaged/user-interaction/focus-navigation/test-002.html |
+++ b/third_party/WebKit/LayoutTests/imported/web-platform-tests/shadow-dom/untriaged/user-interaction/focus-navigation/test-002.html |
@@ -16,7 +16,8 @@ policies and contribution forms [3]. |
<meta name="assert" content="User Interaction: The navigation order within a shadow tree must be computed as a list of focusable elements in tree order as-rendered with the exception of any elements, distributed its insertion points, and is called shadow DOM navigation order."> |
<script src="../../../../../../resources/testharness.js"></script> |
<script src="../../../../../../resources/testharnessreport.js"></script> |
-<script src="../../testcommon.js"></script> |
+<script src="../../../../html/resources/common.js"></script> |
+<script src="../../../resources/shadow-dom-utils.js"></script> |
</head> |
<body> |
<div id="log"></div> |
@@ -26,99 +27,99 @@ var A_07_02_02_T02 = async_test('A_07_02_02_T02'); |
A_07_02_02_T01.step(unit(function (ctx) { |
- var counter = 0; |
- |
- var expectations = []; |
- |
- var d = newRenderedHTMLDocument(ctx); |
- |
- var host = d.createElement('div'); |
- d.body.appendChild(host); |
- |
- var chb1 = d.createElement('input'); |
- chb1.setAttribute('type', 'checkbox'); |
- chb1.setAttribute('id', 'chb1'); |
- chb1.addEventListener('focus', A_07_02_02_T01.step_func(function(event) { |
- assert_true(false, 'Element shouldn\'t be rendered'); |
- }), false); |
- host.appendChild(chb1); |
- |
- var chb2 = d.createElement('input'); |
- chb2.setAttribute('type', 'checkbox'); |
- chb2.setAttribute('id', 'chb2'); |
- chb2.setAttribute('class', 'shadow'); |
- chb2.addEventListener('focus', A_07_02_02_T01.step_func(function(event) { |
- assert_equals(counter++, 0, 'Point 1: wrong focus navigation order'); |
- expectations[1] = true; |
- }), false); |
- expectations[1] = false; |
- host.appendChild(chb2); |
- |
- var chb3 = d.createElement('input'); |
- chb3.setAttribute('type', 'checkbox'); |
- chb3.setAttribute('id', 'chb3'); |
- chb3.setAttribute('class', 'shadow'); |
- chb3.addEventListener('focus', A_07_02_02_T01.step_func(function(event) { |
- assert_equals(counter++, 1, 'Point 2: wrong focus navigation order'); |
- expectations[2] = true; |
- }), false); |
- expectations[2] = false; |
- host.appendChild(chb3); |
- |
- var s = host.createShadowRoot(); |
- |
- var div = d.createElement('div'); |
- div.innerHTML = '<content select=".shadow"></content>'; |
- s.appendChild(div); |
- |
- var inp1 = d.createElement('input'); |
- inp1.setAttribute('type', 'text'); |
- inp1.setAttribute('id', 'shInp1'); |
- inp1.setAttribute('value', 'Input 1'); |
- inp1.addEventListener('focus', A_07_02_02_T01.step_func(function(event) { |
- expectations[3] = false; |
- }), false); |
- expectations[3] = true; |
- s.appendChild(inp1); |
- |
- var inp2 = d.createElement('input'); |
- inp2.setAttribute('type', 'text'); |
- inp2.setAttribute('id', 'shInp2'); |
- inp2.setAttribute('value', 'Input 2'); |
- inp2.addEventListener('focus', A_07_02_02_T01.step_func(function(event) { |
- expectations[4] = false; |
- }), false); |
- expectations[4] = true; |
- s.appendChild(inp2); |
- |
- var chb4 = d.createElement('input'); |
- chb4.setAttribute('type', 'checkbox'); |
- chb4.setAttribute('id', 'chb4'); |
- chb4.addEventListener('focus', A_07_02_02_T01.step_func(function(event) { |
- assert_equals(counter++, 2, 'Point 5: wrong focus navigation order'); |
- expectations[5] = true; |
- }), false); |
- expectations[5] = false; |
- d.body.appendChild(chb4); |
- |
- chb2.focus(); |
- |
- //simulate TAB clicks |
- fireKeyboardEvent(d, chb2, 'U+0009'); |
- |
- fireKeyboardEvent(d, chb3, 'U+0009'); |
- |
- fireKeyboardEvent(d, inp1, 'U+0009'); |
- |
- fireKeyboardEvent(d, inp2, 'U+0009'); |
- |
- fireKeyboardEvent(d, chb4, 'U+0009'); |
- |
- for (var i = 1; i < expectations.length; i++) { |
- if (!expectations[i]) { |
- assert_true(false, 'Point ' + i + ' event listener was not invoked'); |
- } |
- } |
+ var counter = 0; |
+ |
+ var expectations = []; |
+ |
+ var d = newRenderedHTMLDocument(ctx); |
+ |
+ var host = d.createElement('div'); |
+ d.body.appendChild(host); |
+ |
+ var chb1 = d.createElement('input'); |
+ chb1.setAttribute('type', 'checkbox'); |
+ chb1.setAttribute('id', 'chb1'); |
+ chb1.addEventListener('focus', A_07_02_02_T01.step_func(function(event) { |
+ assert_true(false, 'Element shouldn\'t be rendered'); |
+ }), false); |
+ host.appendChild(chb1); |
+ |
+ var chb2 = d.createElement('input'); |
+ chb2.setAttribute('type', 'checkbox'); |
+ chb2.setAttribute('id', 'chb2'); |
+ chb2.setAttribute('slot', 'shadow'); |
+ chb2.addEventListener('focus', A_07_02_02_T01.step_func(function(event) { |
+ assert_equals(counter++, 0, 'Point 1: wrong focus navigation order'); |
+ expectations[1] = true; |
+ }), false); |
+ expectations[1] = false; |
+ host.appendChild(chb2); |
+ |
+ var chb3 = d.createElement('input'); |
+ chb3.setAttribute('type', 'checkbox'); |
+ chb3.setAttribute('id', 'chb3'); |
+ chb3.setAttribute('slot', 'shadow'); |
+ chb3.addEventListener('focus', A_07_02_02_T01.step_func(function(event) { |
+ assert_equals(counter++, 1, 'Point 2: wrong focus navigation order'); |
+ expectations[2] = true; |
+ }), false); |
+ expectations[2] = false; |
+ host.appendChild(chb3); |
+ |
+ var s = host.attachShadow({mode: 'open'}); |
+ |
+ var div = d.createElement('div'); |
+ div.innerHTML = '<slot name="shadow"></slot>'; |
+ s.appendChild(div); |
+ |
+ var inp1 = d.createElement('input'); |
+ inp1.setAttribute('type', 'text'); |
+ inp1.setAttribute('id', 'shInp1'); |
+ inp1.setAttribute('value', 'Input 1'); |
+ inp1.addEventListener('focus', A_07_02_02_T01.step_func(function(event) { |
+ expectations[3] = false; |
+ }), false); |
+ expectations[3] = true; |
+ s.appendChild(inp1); |
+ |
+ var inp2 = d.createElement('input'); |
+ inp2.setAttribute('type', 'text'); |
+ inp2.setAttribute('id', 'shInp2'); |
+ inp2.setAttribute('value', 'Input 2'); |
+ inp2.addEventListener('focus', A_07_02_02_T01.step_func(function(event) { |
+ expectations[4] = false; |
+ }), false); |
+ expectations[4] = true; |
+ s.appendChild(inp2); |
+ |
+ var chb4 = d.createElement('input'); |
+ chb4.setAttribute('type', 'checkbox'); |
+ chb4.setAttribute('id', 'chb4'); |
+ chb4.addEventListener('focus', A_07_02_02_T01.step_func(function(event) { |
+ assert_equals(counter++, 2, 'Point 5: wrong focus navigation order'); |
+ expectations[5] = true; |
+ }), false); |
+ expectations[5] = false; |
+ d.body.appendChild(chb4); |
+ |
+ chb2.focus(); |
+ |
+ //simulate TAB clicks |
+ fireKeyboardEvent(d, chb2, 'U+0009'); |
+ |
+ fireKeyboardEvent(d, chb3, 'U+0009'); |
+ |
+ fireKeyboardEvent(d, inp1, 'U+0009'); |
+ |
+ fireKeyboardEvent(d, inp2, 'U+0009'); |
+ |
+ fireKeyboardEvent(d, chb4, 'U+0009'); |
+ |
+ for (var i = 1; i < expectations.length; i++) { |
+ if (!expectations[i]) { |
+ assert_true(false, 'Point ' + i + ' event listener was not invoked'); |
+ } |
+ } |
A_07_02_02_T01.done(); |
})); |
@@ -127,108 +128,108 @@ A_07_02_02_T01.step(unit(function (ctx) { |
A_07_02_02_T02.step(unit(function (ctx) { |
- var counter = 0; |
+ var counter = 0; |
- var expectations = []; |
+ var expectations = []; |
- var d = newRenderedHTMLDocument(ctx); |
+ var d = newRenderedHTMLDocument(ctx); |
- var chb0 = d.createElement('input'); |
- chb0.setAttribute('type', 'checkbox'); |
- chb0.setAttribute('id', 'chb0'); |
+ var chb0 = d.createElement('input'); |
+ chb0.setAttribute('type', 'checkbox'); |
+ chb0.setAttribute('id', 'chb0'); |
d.body.appendChild(chb0); |
- var host = d.createElement('div'); |
- d.body.appendChild(host); |
- |
- var chb1 = d.createElement('input'); |
- chb1.setAttribute('type', 'checkbox'); |
- chb1.setAttribute('id', 'chb1'); |
- chb1.addEventListener('focus', A_07_02_02_T02.step_func(function(event) { |
- assert_true(false, 'Element shouldn\'t be rendered'); |
- }), false); |
- host.appendChild(chb1); |
- |
- var chb2 = d.createElement('input'); |
- chb2.setAttribute('type', 'checkbox'); |
- chb2.setAttribute('id', 'chb2'); |
- chb2.setAttribute('class', 'shadow'); |
- chb2.addEventListener('focus', A_07_02_02_T02.step_func(function(event) { |
- assert_equals(counter++, 2, 'Point 3: wrong focus navigation order'); |
- expectations[1] = true; |
- }), false); |
- expectations[1] = false; |
- host.appendChild(chb2); |
- |
- var chb3 = d.createElement('input'); |
- chb3.setAttribute('type', 'checkbox'); |
- chb3.setAttribute('id', 'chb3'); |
- chb3.setAttribute('class', 'shadow'); |
- chb3.addEventListener('focus', A_07_02_02_T02.step_func(function(event) { |
- assert_equals(counter++, 3, 'Point 4: wrong focus navigation order'); |
- expectations[2] = true; |
- }), false); |
- expectations[2] = false; |
- host.appendChild(chb3); |
- |
- var s = host.createShadowRoot(); |
- |
- var div = d.createElement('div'); |
- div.innerHTML = '<content select=".shadow"></content>'; |
- s.appendChild(div); |
- |
- var inp1 = d.createElement('input'); |
- inp1.setAttribute('type', 'text'); |
- inp1.setAttribute('id', 'shInp1'); |
- inp1.setAttribute('value', 'Input 1'); |
- inp1.addEventListener('focus', A_07_02_02_T02.step_func(function(event) { |
- assert_equals(counter++, 0, 'Point 1: wrong focus navigation order'); |
- |
- expectations[3] = true; |
- }), false); |
- expectations[3] = false; |
- s.appendChild(inp1); |
- |
- var inp2 = d.createElement('input'); |
- inp2.setAttribute('type', 'text'); |
- inp2.setAttribute('id', 'shInp2'); |
- inp2.setAttribute('value', 'Input 2'); |
- inp2.addEventListener('focus', A_07_02_02_T02.step_func(function(event) { |
- assert_equals(counter++, 1, 'Point 2: wrong focus navigation order'); |
- expectations[4] = true; |
- }), false); |
- expectations[4] = false; |
- s.appendChild(inp2); |
- |
- var chb4 = d.createElement('input'); |
- chb4.setAttribute('type', 'checkbox'); |
- chb4.setAttribute('id', 'chb4'); |
- chb4.addEventListener('focus', A_07_02_02_T02.step_func(function(event) { |
- assert_equals(counter++, 4, 'Point 5: wrong focus navigation order'); |
- expectations[5] = true; |
- }), false); |
- expectations[5] = false; |
- d.body.appendChild(chb4); |
- |
- chb0.focus(); |
- |
- //simulate TAB clicks |
- fireKeyboardEvent(d, inp1, 'U+0009'); |
- |
- fireKeyboardEvent(d, inp2, 'U+0009'); |
- |
- fireKeyboardEvent(d, chb2, 'U+0009'); |
- |
- fireKeyboardEvent(d, chb3, 'U+0009'); |
- |
- fireKeyboardEvent(d, chb4, 'U+0009'); |
- |
- for (var i = 1; i < expectations.length; i++) { |
- if (!expectations[i]) { |
- assert_true(false, 'Point ' + i + ' event listener was not invoked'); |
- } |
- } |
+ var host = d.createElement('div'); |
+ d.body.appendChild(host); |
+ |
+ var chb1 = d.createElement('input'); |
+ chb1.setAttribute('type', 'checkbox'); |
+ chb1.setAttribute('id', 'chb1'); |
+ chb1.addEventListener('focus', A_07_02_02_T02.step_func(function(event) { |
+ assert_true(false, 'Element shouldn\'t be rendered'); |
+ }), false); |
+ host.appendChild(chb1); |
+ |
+ var chb2 = d.createElement('input'); |
+ chb2.setAttribute('type', 'checkbox'); |
+ chb2.setAttribute('id', 'chb2'); |
+ chb2.setAttribute('slot', 'shadow'); |
+ chb2.addEventListener('focus', A_07_02_02_T02.step_func(function(event) { |
+ assert_equals(counter++, 2, 'Point 3: wrong focus navigation order'); |
+ expectations[1] = true; |
+ }), false); |
+ expectations[1] = false; |
+ host.appendChild(chb2); |
+ |
+ var chb3 = d.createElement('input'); |
+ chb3.setAttribute('type', 'checkbox'); |
+ chb3.setAttribute('id', 'chb3'); |
+ chb3.setAttribute('slot', 'shadow'); |
+ chb3.addEventListener('focus', A_07_02_02_T02.step_func(function(event) { |
+ assert_equals(counter++, 3, 'Point 4: wrong focus navigation order'); |
+ expectations[2] = true; |
+ }), false); |
+ expectations[2] = false; |
+ host.appendChild(chb3); |
+ |
+ var s = host.attachShadow({mode: 'open'}); |
+ |
+ var div = d.createElement('div'); |
+ div.innerHTML = '<slot name="shadow"></slot>'; |
+ s.appendChild(div); |
+ |
+ var inp1 = d.createElement('input'); |
+ inp1.setAttribute('type', 'text'); |
+ inp1.setAttribute('id', 'shInp1'); |
+ inp1.setAttribute('value', 'Input 1'); |
+ inp1.addEventListener('focus', A_07_02_02_T02.step_func(function(event) { |
+ assert_equals(counter++, 0, 'Point 1: wrong focus navigation order'); |
+ |
+ expectations[3] = true; |
+ }), false); |
+ expectations[3] = false; |
+ s.appendChild(inp1); |
+ |
+ var inp2 = d.createElement('input'); |
+ inp2.setAttribute('type', 'text'); |
+ inp2.setAttribute('id', 'shInp2'); |
+ inp2.setAttribute('value', 'Input 2'); |
+ inp2.addEventListener('focus', A_07_02_02_T02.step_func(function(event) { |
+ assert_equals(counter++, 1, 'Point 2: wrong focus navigation order'); |
+ expectations[4] = true; |
+ }), false); |
+ expectations[4] = false; |
+ s.appendChild(inp2); |
+ |
+ var chb4 = d.createElement('input'); |
+ chb4.setAttribute('type', 'checkbox'); |
+ chb4.setAttribute('id', 'chb4'); |
+ chb4.addEventListener('focus', A_07_02_02_T02.step_func(function(event) { |
+ assert_equals(counter++, 4, 'Point 5: wrong focus navigation order'); |
+ expectations[5] = true; |
+ }), false); |
+ expectations[5] = false; |
+ d.body.appendChild(chb4); |
+ |
+ chb0.focus(); |
+ |
+ //simulate TAB clicks |
+ fireKeyboardEvent(d, inp1, 'U+0009'); |
+ |
+ fireKeyboardEvent(d, inp2, 'U+0009'); |
+ |
+ fireKeyboardEvent(d, chb2, 'U+0009'); |
+ |
+ fireKeyboardEvent(d, chb3, 'U+0009'); |
+ |
+ fireKeyboardEvent(d, chb4, 'U+0009'); |
+ |
+ for (var i = 1; i < expectations.length; i++) { |
+ if (!expectations[i]) { |
+ assert_true(false, 'Point ' + i + ' event listener was not invoked'); |
+ } |
+ } |
A_07_02_02_T02.done(); |
})); |