Skip to content

Commit

Permalink
fix: align AbortSignal to spec using WPT (#9007)
Browse files Browse the repository at this point in the history
  • Loading branch information
lucacasonato authored Jan 5, 2021
1 parent 096e090 commit 7704839
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 3 deletions.
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

0 comments on commit 7704839

Please sign in to comment.