Skip to content

Commit

Permalink
[ComputePressure] Use AbortError for unobserve/disconnect method
Browse files Browse the repository at this point in the history
According to the spec [1][2], pendingPromise should reject with an
AbortError when calling unobserve/disconnect method.

[1] https://www.w3.org/TR/compute-pressure/#the-unobserve-method
[2] https://www.w3.org/TR/compute-pressure/#the-disconnect-method

Bug: none
Change-Id: Icd83d62ae391738d883ba249d27a366673d48094
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4738336
Commit-Queue: Wei4 Wang <[email protected]>
Reviewed-by: Raphael Kubo Da Costa <[email protected]>
Reviewed-by: Kenneth R Christiansen <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1178888}
  • Loading branch information
wangw-1991 authored and chromium-wpt-export-bot committed Aug 3, 2023
1 parent a2121f9 commit b9998d2
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ pressure_test((t, mockPressureService) => {
mockPressureService.setPressureUpdate('cpu', 'critical');
mockPressureService.startPlatformCollector(/*sampleRate=*/ 5.0);

return promise_rejects_dom(t, 'NotSupportedError', promise);
return promise_rejects_dom(t, 'AbortError', promise);
}, 'Removing observer before observe() resolves works');

pressure_test(async (t, mockPressureService) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pressure_test(async (t, mockPressureService) => {
const promise = observer1.observe('cpu');
observer1.disconnect();
observer1.disconnect();
await promise_rejects_dom(t, 'NotSupportedError', promise);
await promise_rejects_dom(t, 'AbortError', promise);

const observer2_changes = [];
await new Promise((resolve, reject) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pressure_test(async (t, mockPressureService) => {
// Ensure that observer1's schema gets registered before observer2 starts.
const promise = observer1.observe('cpu');
observer1.disconnect();
await promise_rejects_dom(t, 'NotSupportedError', promise);
await promise_rejects_dom(t, 'AbortError', promise);

const observer2_changes = [];
await new Promise((resolve, reject) => {
Expand Down Expand Up @@ -53,7 +53,7 @@ pressure_test(async (t, mockPressureService) => {
const promise = observer1.observe('cpu');
observer2.observe('cpu');
observer1.disconnect();
await promise_rejects_dom(t, 'NotSupportedError', promise);
await promise_rejects_dom(t, 'AbortError', promise);
mockPressureService.setPressureUpdate('cpu', 'critical');
mockPressureService.startPlatformCollector(/*sampleRate=*/ 5.0);
});
Expand Down

0 comments on commit b9998d2

Please sign in to comment.