forked from mykmelez/gecko
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug 1556663 [wpt PR 17159] - Add optional test for cloning of error s…
…tacks, a=testonly Automatic update from web-platform-tests Add optional test for cloning of error stacks Supplements web-platform-tests/wpt#17095. Follows whatwg/html#4665 and whatwg/webidl#732. -- wpt-commits: 1da6bed5d8c4c38200383b86928b7be68bfb87da wpt-pr: 17159
- Loading branch information
Showing
8 changed files
with
100 additions
and
12 deletions.
There are no files selected for viewing
1 change: 0 additions & 1 deletion
1
testing/web-platform/tests/html/infrastructure/safe-passing-of-structured-data/echo.js
This file was deleted.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ | |
<link rel="author" title="Domenic Denicola" href="mailto:[email protected]"> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script src="/common/utils.js"></script> | ||
<script src="resources/test-sab.js"></script> | ||
|
||
<div id="log"></div> | ||
|
@@ -13,9 +14,10 @@ | |
"use strict"; | ||
|
||
async_test(t => { | ||
const testId = token(); | ||
const sab = new SharedArrayBuffer(1); | ||
window.addEventListener("message", t.step_func(({ data }) => { | ||
if (data.testId !== 1) { | ||
if (data.testId !== testId) { | ||
return; | ||
} | ||
|
||
|
@@ -24,29 +26,31 @@ | |
t.done(); | ||
})); | ||
|
||
window.postMessage({ sab, testId: 1 }, "*"); | ||
window.postMessage({ testId, sab }, "*"); | ||
}, "postMessaging to this window does not give back the same SharedArrayBuffer (but does use the same backing block)"); | ||
|
||
async_test(t => { | ||
const testId = token(); | ||
const sab = new SharedArrayBuffer(); | ||
const worker = new Worker("resources/echo-worker.js"); | ||
const worker = new Worker("../resources/echo-worker.js"); | ||
|
||
worker.addEventListener("message", t.step_func(({ data }) => { | ||
if (data.testId !== 2) { | ||
if (data.testId !== testId) { | ||
return; | ||
} | ||
|
||
assert_not_equals(data.sab, sab); | ||
t.done(); | ||
})); | ||
|
||
worker.postMessage({ testId: 2, sab }); | ||
worker.postMessage({ testId, sab }); | ||
}, "postMessaging to a worker and back does not give back the same SharedArrayBuffer"); | ||
|
||
async_test(t => { | ||
const testId = token(); | ||
const sab = new SharedArrayBuffer(); | ||
window.addEventListener("message", t.step_func(({ data }) => { | ||
if (data.testId !== 3) { | ||
if (data.testId !== testId) { | ||
return; | ||
} | ||
|
||
|
@@ -56,9 +60,9 @@ | |
|
||
const iframe = document.createElement("iframe"); | ||
iframe.onload = t.step_func(() => { | ||
iframe.contentWindow.postMessage({ testId: 3, sab }, "*"); | ||
iframe.contentWindow.postMessage({ testId, sab }, "*"); | ||
}); | ||
iframe.src = "resources/echo-iframe.html"; | ||
iframe.src = "../resources/echo-iframe.html"; | ||
document.body.appendChild(iframe); | ||
}, "postMessaging to an iframe and back does not give back the same SharedArrayBuffer"); | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
85 changes: 85 additions & 0 deletions
85
...ure/safe-passing-of-structured-data/structured-cloning-error-stack-optional.sub.window.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
// META: script=/common/utils.js | ||
|
||
// .stack properties on errors are unspecified, but are present in most | ||
// browsers, most of the time. https://github.com/tc39/proposal-error-stacks/ tracks standardizing them. | ||
// Tests will pass automatically if the .stack property isn't present. | ||
|
||
stackTests(() => { | ||
return new Error('some message'); | ||
}, 'page-created Error'); | ||
|
||
stackTests(() => { | ||
return new DOMException('InvalidStateError', 'some message'); | ||
}, 'page-created DOMException'); | ||
|
||
stackTests(() => { | ||
try { | ||
Object.defineProperty(); | ||
} catch (e) { | ||
return e; | ||
} | ||
}, 'JS-engine-created TypeError'); | ||
|
||
stackTests(() => { | ||
try { | ||
HTMLParagraphElement.prototype.align; | ||
} catch (e) { | ||
return e; | ||
} | ||
}, 'web API-created TypeError'); | ||
|
||
stackTests(() => { | ||
try { | ||
document.createElement(''); | ||
} catch (e) { | ||
return e; | ||
} | ||
}, 'web API-created DOMException'); | ||
|
||
function stackTests(errorFactory, description) { | ||
async_test(t => { | ||
const error = errorFactory(); | ||
const originalStack = error.stack; | ||
|
||
if (!originalStack) { | ||
t.done(); | ||
return; | ||
} | ||
|
||
const worker = new Worker('resources/echo-worker.js'); | ||
worker.onmessage = t.step_func_done(e => { | ||
assert_equals(e.data.stack, originalStack); | ||
}); | ||
|
||
worker.postMessage(error); | ||
}, description + ' (worker)'); | ||
|
||
async_test(t => { | ||
const thisTestId = token(); | ||
|
||
const error = errorFactory(); | ||
const originalStack = error.stack; | ||
|
||
if (!originalStack) { | ||
t.done(); | ||
return; | ||
} | ||
|
||
const iframe = document.createElement('iframe'); | ||
window.addEventListener('message', t.step_func(e => { | ||
if (e.data.testId === thisTestId) { | ||
assert_equals(e.data.error.stack, originalStack); | ||
t.done(); | ||
} | ||
})); | ||
|
||
iframe.onload = t.step_func(() => { | ||
iframe.contentWindow.postMessage({ error, testId: thisTestId }, "*"); | ||
}); | ||
|
||
const crossSiteEchoIFrame = new URL('resources/echo-iframe.html', location.href); | ||
crossSiteEchoIFrame.hostname = '{{hosts[alt][www1]}}'; | ||
iframe.src = crossSiteEchoIFrame; | ||
document.body.append(iframe); | ||
}, description + ' (cross-site iframe)'); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters