Skip to content

Commit

Permalink
Remove error.message in SharedWorker WPT (web-platform-tests#21287)
Browse files Browse the repository at this point in the history
error of SharedWorker is |Event| type or |ErrorEvent|.
This CL removes error.message because |Event| doesn't have |message| property.
https://html.spec.whatwg.org/multipage/indices.html#event-error

Bug: 1043634
Change-Id: Id7ff6b4222c56b770457731694f07fd850504681
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2011621
Reviewed-by: Hiroki Nakagawa <[email protected]>
Commit-Queue: Eriko Kurimoto <[email protected]>
Cr-Commit-Position: refs/heads/master@{#733909}
  • Loading branch information
chromium-wpt-export-bot authored and stephenmcgruer committed Jan 22, 2020
1 parent b2cd48a commit 91ce17c
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 8 deletions.
6 changes: 5 additions & 1 deletion workers/modules/dedicated-worker-import-blob-url.any.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@ function import_blob_url_test(testCase) {
worker.postMessage('Send message for tests from main script.');
const msgEvent = await new Promise((resolve, reject) => {
worker.onmessage = resolve;
worker.onerror = (error) => reject(error && error.message);
worker.onerror = error => {
const msg = error instanceof ErrorEvent ? error.message
: 'unknown error';
reject(msg);
};
});
assert_array_equals(msgEvent.data, testCase.expectation);
}, testCase.description);
Expand Down
6 changes: 5 additions & 1 deletion workers/modules/dedicated-worker-import-failure.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,11 @@
worker.postMessage(scriptURL);
const msg_event = await new Promise((resolve, reject) => {
worker.onmessage = resolve;
worker.onerror = (error) => reject(error && error.message);
worker.onerror = error => {
const msg = error instanceof ErrorEvent ? error.message
: 'unknown error';
reject(msg);
};
});
assert_equals(msg_event.data, 'TypeError');
}, 'Dynamic import for non-existent script should throw an exception.');
Expand Down
18 changes: 15 additions & 3 deletions workers/modules/dedicated-worker-import-meta.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@
const worker = new Worker(script_url, { type: 'module' });
return new Promise((resolve, reject) => {
worker.onmessage = resolve;
worker.onerror = (error) => reject(error && error.message);
worker.onerror = error => {
const msg = error instanceof ErrorEvent ? error.message
: 'unknown error';
reject(msg);
};
})
.then(msg_event => assert_true(msg_event.data.endsWith(script_url)));
}, 'Test import.meta.url on the top-level module script.');
Expand All @@ -21,7 +25,11 @@
worker.postMessage('./' + script_url);
return new Promise((resolve, reject) => {
worker.onmessage = resolve;
worker.onerror = (error) => reject(error && error.message);
worker.onerror = error => {
const msg = error instanceof ErrorEvent ? error.message
: 'unknown error';
reject(msg);
};
})
.then(msg_event => assert_true(msg_event.data.endsWith(script_url)));
}, 'Test import.meta.url on the imported module script.');
Expand All @@ -34,7 +42,11 @@

return new Promise((resolve, reject) => {
worker.onmessage = resolve;
worker.onerror = (error) => reject(error && error.message);
worker.onerror = error => {
const msg = error instanceof ErrorEvent ? error.message
: 'unknown error';
reject(msg);
};
})
.then(msg_event => assert_true(msg_event.data.endsWith(script_url)))
.then(() => {
Expand Down
6 changes: 5 additions & 1 deletion workers/modules/dedicated-worker-import.any.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ function import_test(testCase) {
worker.postMessage('Send message for tests from main script.');
const msgEvent = await new Promise((resolve, reject) => {
worker.onmessage = resolve;
worker.onerror = (error) => reject(error && error.message);
worker.onerror = error => {
const msg = error instanceof ErrorEvent ? error.message
: 'unknown error';
reject(msg);
};
});
assert_array_equals(msgEvent.data, testCase.expectation);
}, testCase.description);
Expand Down
6 changes: 5 additions & 1 deletion workers/modules/shared-worker-import-blob-url.any.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@ function import_blob_url_test(testCase) {
worker.port.postMessage('Send message for tests from main script.');
const msgEvent = await new Promise((resolve, reject) => {
worker.port.onmessage = resolve;
worker.onerror = (error) => reject(error && error.message);
worker.onerror = error => {
const msg = error instanceof ErrorEvent ? error.message
: 'unknown error';
reject(msg);
};
});
assert_array_equals(msgEvent.data, testCase.expectation);
}, testCase.description);
Expand Down
6 changes: 5 additions & 1 deletion workers/modules/shared-worker-import.any.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ function import_test(testCase) {
worker.port.postMessage('Send message for tests from main script.');
const msgEvent = await new Promise((resolve, reject) => {
worker.port.onmessage = resolve;
worker.onerror = (error) => reject(error && error.message);
worker.onerror = error => {
const msg = error instanceof ErrorEvent ? error.message
: 'unknown error';
reject(msg);
};
});
assert_array_equals(msgEvent.data, testCase.expectation);
}, testCase.description);
Expand Down

0 comments on commit 91ce17c

Please sign in to comment.