Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: align AbortSignal to spec using WPT #9007

Merged
merged 3 commits into from
Jan 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions cli/tests/wpt.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,13 @@
"api-invalid-label",
"api-replacement-encodings",
"api-surrogates-utf8",
// TODO(lucacasonato): enable encodeInto. It is buggy at the moment.
// TODO(lucacasonato): enable encodeInto. We have a bug in implementaiton.
// {
// "name": "encodeInto",
// "expectFail": [
// "encodeInto() and a detached output buffer"
// ]
// },
// "encodeInto",
// TODO(lucacasonato): enable when we support iso-2022-jp
// "iso-2022-jp-decoder",
Expand Down Expand Up @@ -110,7 +116,7 @@
"utf-16le => UTF-16LE",
"x-user-defined => x-user-defined"
]
}
},
// TODO(lucacasonato): enable when we have stream support
// "textdecoder-streaming",
// TODO(lucacasonato): enable when we support utf-16
Expand All @@ -134,5 +140,8 @@
// "textencoder-utf16-surrogates",
// TODO(lucacasonato): uses XMLHttpRequest unnecessarily. should be fixed upstream before enabling
// "unsupported-encodings",
],
"dom": [
"abort/event"
]
}
10 changes: 10 additions & 0 deletions op_crates/web/01_event.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,13 @@
event.currentTarget = value;
}

function setIsTrusted(event, value) {
const data = eventData.get(event);
if (data) {
data.isTrusted = value;
}
}

function setDispatched(event, value) {
const data = eventData.get(event);
if (data) {
Expand Down Expand Up @@ -1185,4 +1192,7 @@
window.__bootstrap.eventTarget = {
setEventTargetData,
};
window.__bootstrap.event = {
setIsTrusted,
};
})(this);
6 changes: 5 additions & 1 deletion op_crates/web/02_abort_signal.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.

((window) => {
const { setIsTrusted } = window.__bootstrap.event;

const add = Symbol("add");
const signalAbort = Symbol("signalAbort");
const remove = Symbol("remove");
Expand All @@ -24,7 +26,9 @@
algorithm();
}
this.#abortAlgorithms.clear();
this.dispatchEvent(new Event("abort"));
const event = new Event("abort");
setIsTrusted(event, true);
this.dispatchEvent(event);
}

[remove](algorithm) {
Expand Down