Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit da612df

Browse filesBrowse files
watildetargos
authored andcommitted
test: integrate abort_controller tests from wpt
Refs: web-platform-tests/wpt#9361 PR-URL: #35869 Refs: https://github.com/web-platform-tests/wpt/blob/master/dom/abort/event.any.js Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
1 parent d2f574b commit da612df
Copy full SHA for da612df

File tree

Expand file treeCollapse file tree

6 files changed

+87
-1
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

6 files changed

+87
-1
lines changed
Open diff view settings
Collapse file

‎test/fixtures/wpt/README.md‎

Copy file name to clipboardExpand all lines: test/fixtures/wpt/README.md
+1Lines changed: 1 addition & 0 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ Last update:
1919
- html/webappapis/timers: https://github.com/web-platform-tests/wpt/tree/264f12bc7b/html/webappapis/timers
2020
- hr-time: https://github.com/web-platform-tests/wpt/tree/a5d1774ecf/hr-time
2121
- common: https://github.com/web-platform-tests/wpt/tree/4dacb6e2ff/common
22+
- dom/abort: https://github.com/web-platform-tests/wpt/tree/7caa3de747/dom/abort
2223

2324
[Web Platform Tests]: https://github.com/web-platform-tests/wpt
2425
[`git node wpt`]: https://github.com/nodejs/node-core-utils/blob/master/docs/git-node.md#git-node-wpt
Collapse file
+67Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
test(t => {
2+
const c = new AbortController(),
3+
s = c.signal;
4+
let state = "begin";
5+
6+
assert_false(s.aborted);
7+
8+
s.addEventListener("abort",
9+
t.step_func(e => {
10+
assert_equals(state, "begin");
11+
state = "aborted";
12+
})
13+
);
14+
c.abort();
15+
16+
assert_equals(state, "aborted");
17+
assert_true(s.aborted);
18+
19+
c.abort();
20+
}, "AbortController abort() should fire event synchronously");
21+
22+
test(t => {
23+
const controller = new AbortController();
24+
const signal = controller.signal;
25+
assert_equals(controller.signal, signal,
26+
"value of controller.signal should not have changed");
27+
controller.abort();
28+
assert_equals(controller.signal, signal,
29+
"value of controller.signal should still not have changed");
30+
}, "controller.signal should always return the same object");
31+
32+
test(t => {
33+
const controller = new AbortController();
34+
const signal = controller.signal;
35+
let eventCount = 0;
36+
signal.onabort = () => {
37+
++eventCount;
38+
};
39+
controller.abort();
40+
assert_true(signal.aborted);
41+
assert_equals(eventCount, 1, "event handler should have been called once");
42+
controller.abort();
43+
assert_true(signal.aborted);
44+
assert_equals(eventCount, 1,
45+
"event handler should not have been called again");
46+
}, "controller.abort() should do nothing the second time it is called");
47+
48+
test(t => {
49+
const controller = new AbortController();
50+
controller.abort();
51+
controller.signal.onabort =
52+
t.unreached_func("event handler should not be called");
53+
}, "event handler should not be called if added after controller.abort()");
54+
55+
test(t => {
56+
const controller = new AbortController();
57+
const signal = controller.signal;
58+
signal.onabort = t.step_func(e => {
59+
assert_equals(e.type, "abort", "event type should be abort");
60+
assert_equals(e.target, signal, "event target should be signal");
61+
assert_false(e.bubbles, "event should not bubble");
62+
assert_true(e.isTrusted, "event should be trusted");
63+
});
64+
controller.abort();
65+
}, "the abort event should have the right properties");
66+
67+
done();
Collapse file

‎test/fixtures/wpt/versions.json‎

Copy file name to clipboardExpand all lines: test/fixtures/wpt/versions.json
+5-1Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,9 @@
3434
"common": {
3535
"commit": "4dacb6e2ff8dbabbe328fde2d8c75491598e4c10",
3636
"path": "common"
37+
},
38+
"dom/abort": {
39+
"commit": "7caa3de7471cf19b78ee9efa313c7341a462b5e3",
40+
"path": "dom/abort"
3741
}
38-
}
42+
}
Collapse file

‎test/parallel/test-eventtarget.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-eventtarget.js
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -479,3 +479,9 @@ let asyncTest = Promise.resolve();
479479
throws(() => eventTarget.addEventListener('foo', Symbol()), TypeError);
480480
});
481481
}
482+
{
483+
const eventTarget = new EventTarget();
484+
const event = new Event('foo');
485+
eventTarget.dispatchEvent(event);
486+
strictEqual(event.target, eventTarget);
487+
}
Collapse file

‎test/wpt/status/dom/abort.json‎

Copy file name to clipboard
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}
Collapse file

‎test/wpt/test-abort.js‎

Copy file name to clipboard
+7Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
'use strict';
2+
require('../common');
3+
const { WPTRunner } = require('../common/wpt');
4+
5+
const runner = new WPTRunner('dom/abort');
6+
7+
runner.runJsTests();

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.