aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbors-servo <lbergstrom+bors@mozilla.com>2016-06-25 14:18:48 -0500
committerGitHub <noreply@github.com>2016-06-25 14:18:48 -0500
commit6a09c36f8181fb359303c33d6fa1f1159e18255a (patch)
treedcbf5a600b9523c8faf93122ea550868c8828753
parent9ee0a01f66b4b6fcbfd86e0316d6aed35ef99ebf (diff)
parent2c35233638c02a0f0d432fae98e50a8c31bb5e72 (diff)
downloadservo-6a09c36f8181fb359303c33d6fa1f1159e18255a.tar.gz
servo-6a09c36f8181fb359303c33d6fa1f1159e18255a.zip
Auto merge of #11865 - paulrouget:doubleFocusTest, r=ConnorGBrewster
Test for double focus events (covers #11665) <!-- Please describe your changes on the following line: --> --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix #11854 (github issue number if applicable). <!-- Either: --> - [x] There are tests for these changes OR - [ ] These changes do not require tests because _____ <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/11865) <!-- Reviewable:end -->
-rw-r--r--tests/wpt/mozilla/meta/MANIFEST.json6
-rw-r--r--tests/wpt/mozilla/tests/mozilla/double_focus.html76
2 files changed, 82 insertions, 0 deletions
diff --git a/tests/wpt/mozilla/meta/MANIFEST.json b/tests/wpt/mozilla/meta/MANIFEST.json
index c66a163d2f7..fff9517a8b1 100644
--- a/tests/wpt/mozilla/meta/MANIFEST.json
+++ b/tests/wpt/mozilla/meta/MANIFEST.json
@@ -6310,6 +6310,12 @@
"url": "/_mozilla/mozilla/document_url.html"
}
],
+ "mozilla/double_focus.html": [
+ {
+ "path": "mozilla/double_focus.html",
+ "url": "/_mozilla/mozilla/double_focus.html"
+ }
+ ],
"mozilla/element_attribute.html": [
{
"path": "mozilla/element_attribute.html",
diff --git a/tests/wpt/mozilla/tests/mozilla/double_focus.html b/tests/wpt/mozilla/tests/mozilla/double_focus.html
new file mode 100644
index 00000000000..89ed38f5086
--- /dev/null
+++ b/tests/wpt/mozilla/tests/mozilla/double_focus.html
@@ -0,0 +1,76 @@
+<!DOCTYPE html>
+
+<html>
+
+ <head>
+ <meta charset="UTF-8">
+ <title>Double focus/blur events</title>
+ <script src="/resources/testharness.js"></script>
+ <script src="/resources/testharnessreport.js"></script>
+ </head>
+
+ <body>
+
+ <input>
+
+ <script>
+
+ async_test(function(t) {
+
+ var input = document.querySelector("input");
+
+ var actions = [
+ input.focus,
+ input.focus,
+ input.blur,
+ input.blur,
+ input.focus,
+ input.focus,
+ input.blur,
+ input.blur,
+ input.focus,
+ ];
+
+ var expected_events = [
+ "focus",
+ "blur",
+ "focus",
+ "blur",
+ "focus",
+ ];
+
+ var received_events = [];
+
+ var action_idx = 0;
+
+ var onEvent = t.step_func(function(e) {
+ received_events.push(e.type);
+ if (action_idx == actions.length - 1) {
+ // All actions executed
+ assert_array_equals(expected_events, received_events);
+ t.done();
+ }
+ });
+
+ function next() {
+ actions[action_idx].apply(input);
+ action_idx++;
+ if (action_idx < actions.length) {
+ // This can't be done on focus or blur events
+ // as we don't expect focus() to trigger a focus
+ // event if the input was already focused.
+ setTimeout(next, 0);
+ }
+ }
+
+ input.addEventListener("focus", onEvent, false);
+ input.addEventListener("blur", onEvent, false);
+
+ next();
+
+ });
+
+ </script>
+
+ </body>
+</html>