Index: third_party/WebKit/LayoutTests/imported/wpt/uievents/order-of-events/focus-events/focus-manual.html |
diff --git a/third_party/WebKit/LayoutTests/imported/wpt/uievents/order-of-events/focus-events/focus-manual.html b/third_party/WebKit/LayoutTests/imported/wpt/uievents/order-of-events/focus-events/focus-manual.html |
index c91f790e21ede6e2c50f499566e2c179e4115fc3..391daf7028ce7fdff4f78b542caa2dd7d917a0d2 100644 |
--- a/third_party/WebKit/LayoutTests/imported/wpt/uievents/order-of-events/focus-events/focus-manual.html |
+++ b/third_party/WebKit/LayoutTests/imported/wpt/uievents/order-of-events/focus-events/focus-manual.html |
@@ -1,81 +1,74 @@ |
<!DOCTYPE html> |
<html> |
- <head> |
- <meta charset="utf-8"> |
- <title>Focus-related events should fire in the correct order</title> |
- <link rel="author" title="Chris Rebert" href="http://chrisrebert.com"> |
- <link rel="help" href="https://w3c.github.io/uievents/#events-focusevent-event-order"> |
- <meta name="flags" content="interact"> |
- <script src="/resources/testharness.js"></script> |
- <script src="/resources/testharnessreport.js"></script> |
- </head> |
- <body> |
- <ol> |
- <li>Click into the first text input.</li> |
- <li>Click into the second text input.</li> |
- <li>Click the "Done" button.</li> |
- </ol> |
+<head> |
+ <meta charset="utf-8"> |
+ <title>Focus-related events should fire in the correct order</title> |
+ <link rel="author" title="Chris Rebert" href="http://chrisrebert.com"> |
+ <link rel="help" href="https://w3c.github.io/uievents/#events-focusevent-event-order"> |
+ <meta name="flags" content="interact"> |
+ <script src="/resources/testharness.js"></script> |
+ <script src="/resources/testharnessreport.js"></script> |
+ <script src="/uievents/resources/eventrecorder.js"></script> |
+</head> |
- <input type="text" id="a" value="First"> |
- <br> |
- <input type="text" id="b" value="Second"> |
- <br> |
- <button type="button" id="done">Done</button> |
+<body> |
+ <ol> |
+ <li>Click into the first text input.</li> |
+ <li>Click into the second text input.</li> |
+ <li>Click the "Done" button.</li> |
+ </ol> |
+ <input type="text" id="a" value="First"> |
+ <br> |
+ <input type="text" id="b" value="Second"> |
+ <br> |
+ <button type="button" id="done">Done</button> |
+</body> |
- <script> |
+<script> |
setup({explicit_timeout: true}); |
-var done = false; |
-var events = []; |
-var targets = []; |
-function record(e) { |
- if (done) { |
- return; |
- } |
- events.push(e.type); |
- targets.push(e.target.id); |
-} |
-function finish() { |
- done = true; |
+function stopPropagation(e) { |
+ if (event.type == "focusin" || event.type == "focusout") |
+ assert_true(event.bubbles); |
+ e.stopPropagation(); |
} |
var relevantEvents = [ |
- 'focus', |
- 'blur', |
- 'focusin', |
- 'focusout' |
+ "focus", |
+ "blur", |
+ "focusin", |
+ "focusout" |
]; |
window.onload = function () { |
- var a = document.getElementById('a'); |
- var b = document.getElementById('b'); |
+ var a = document.getElementById("a"); |
+ var b = document.getElementById("b"); |
var inputs = [a, b]; |
+ EventRecorder.configure({ |
+ objectMap: { |
+ "a": a, |
+ "b": b, |
+ } |
+ }); |
- b.addEventListener('blur', finish, false); |
- b.addEventListener('focusout', finish, false); |
- |
- for (var i = 0; i < inputs.length; i++) { |
- for (var k = 0; k < relevantEvents.length; k++) { |
- inputs[i].addEventListener(relevantEvents[k], record, false); |
- } |
- } |
+ EventRecorder.addEventListenersForNodes(relevantEvents, inputs, stopPropagation); |
+ var expected = [ |
+ {type: "focusin", target: "a"}, |
+ {type: "focus", target: "a"}, |
+ {type: "focusout", target: "a"}, |
+ {type: "focusin", target: "b"}, |
+ {type: "blur", target: "a"}, |
+ {type: "focus", target: "b"}, |
+ {type: "focusout", target: "b"}, |
+ {type: "blur", target: "b"} |
+ ]; |
async_test(function(t) { |
- document.getElementById('done').addEventListener('click', function () { |
- finish(); |
+ document.getElementById("done").addEventListener("click", function () { |
t.step(function () { |
- assert_array_equals( |
- events, |
- ['focusin', 'focus', 'focusout', 'focusin', 'blur', 'focus'], |
- 'Focus-related events should fire in this order: focusin, focus, focusout, focusin, blur, focus' |
- ); |
- assert_array_equals( |
- targets, |
- [ 'a', 'a', 'a', 'b', 'a', 'b'], |
- 'Focus-related events should fire at the correct targets' |
- ); |
+ assert_true(EventRecorder.checkRecords(expected)); |
t.done(); |
}); |
}, false); |
- }, 'Focus-related events should fire in the correct order'); |
+ }, "Focus-related events should fire in the correct order"); |
+ EventRecorder.start(); |
}; |
- </script> |
- </body> |
+</script> |
</html> |