mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 06:07:44 +00:00
LibWeb: Add initial support for AbortController and AbortSignal
The DOM specification says that the primary use case for these is to give Promises abort semantics. It is also a prerequisite for Fetch, as it is used to make Fetch abortable. a
This commit is contained in:
parent
dd1a49ff93
commit
1d8f8ea5b1
11 changed files with 254 additions and 0 deletions
20
Userland/Libraries/LibWeb/Tests/DOM/AbortController.js
Normal file
20
Userland/Libraries/LibWeb/Tests/DOM/AbortController.js
Normal file
|
@ -0,0 +1,20 @@
|
|||
describe("AbortController", () => {
|
||||
loadLocalPage("/res/html/misc/blank.html");
|
||||
|
||||
afterInitialPageLoad(page => {
|
||||
test("Basic functionality", () => {
|
||||
const abortController = new page.AbortController();
|
||||
let timesCallbackCalled = 0;
|
||||
abortController.signal.addEventListener("abort", () => {
|
||||
timesCallbackCalled++;
|
||||
});
|
||||
|
||||
abortController.abort();
|
||||
expect(abortController.signal.aborted).toBeTrue();
|
||||
|
||||
abortController.abort();
|
||||
expect(timesCallbackCalled).toBe(1);
|
||||
});
|
||||
});
|
||||
waitForPageToLoad();
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue