Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
WebAssembly: sending module to iframe fails
https://bugs.webkit.org/show_bug.cgi?id=179263 Reviewed by JF Bastien. Source/WebCore: Allow use WebAssembly.Module as input parameters for postMessage in window and iframe object. Tests: wasm/iframe-postmessage.html wasm/window-postmessage.html * bindings/js/SerializedScriptValue.cpp: (WebCore::CloneSerializer::dumpIfTerminal): * bindings/js/SerializedScriptValue.h: * page/DOMWindow.cpp: (WebCore::DOMWindow::postMessage): LayoutTests: * platform/ios-simulator/TestExpectations: * platform/win/TestExpectations: * resources/wasm-builder.js: Renamed from LayoutTests/workers/wasm-resources/builder.js. * wasm/iframe-parent-postmessage-expected.txt: Added. * wasm/iframe-parent-postmessage.html: Added. * wasm/iframe-postmessage-expected.txt: Added. * wasm/iframe-postmessage.html: Added. * wasm/resources/frame-parent.html: Added. * wasm/resources/frame.html: Added. * wasm/resources/load_wasm.js: Added. (createWasmModule): * wasm/window-postmessage-expected.txt: Added. * wasm/window-postmessage.html: Added. * workers/wasm-mem-post-message.html: Canonical link: https://commits.webkit.org/196476@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@225656 268f45cc-cd09-0410-ab3c-d52691b4dbfc
- Loading branch information
Showing
with
219 additions
and 4 deletions.
- +22 −0 LayoutTests/ChangeLog
- +3 −0 LayoutTests/platform/ios-simulator/TestExpectations
- +3 −0 LayoutTests/platform/win/TestExpectations
- 0 LayoutTests/{workers/wasm-resources/builder.js → resources/wasm-builder.js}
- +10 −0 LayoutTests/wasm/iframe-parent-postmessage-expected.txt
- +30 −0 LayoutTests/wasm/iframe-parent-postmessage.html
- +10 −0 LayoutTests/wasm/iframe-postmessage-expected.txt
- +30 −0 LayoutTests/wasm/iframe-postmessage.html
- +14 −0 LayoutTests/wasm/resources/frame-parent.html
- +14 −0 LayoutTests/wasm/resources/frame.html
- +19 −0 LayoutTests/wasm/resources/load_wasm.js
- +10 −0 LayoutTests/wasm/window-postmessage-expected.txt
- +31 −0 LayoutTests/wasm/window-postmessage.html
- +1 −1 LayoutTests/workers/wasm-mem-post-message.html
- +19 −0 Source/WebCore/ChangeLog
- +1 −1 Source/WebCore/bindings/js/SerializedScriptValue.cpp
- +1 −1 Source/WebCore/bindings/js/SerializedScriptValue.h
- +1 −1 Source/WebCore/page/DOMWindow.cpp
There are no files selected for viewing
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
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
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
@@ -0,0 +1,10 @@ | ||
Test that expected Wasm Module can be sent over window.parent.postMessage from iframe. | ||
|
||
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". | ||
|
||
|
||
PASS successfullyParsed is true | ||
|
||
TEST COMPLETE | ||
PASS () => value is 35010 | ||
|
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
@@ -0,0 +1,30 @@ | ||
<!DOCTYPE html> | ||
<iframe src="./resources/frame-parent.html" id="iframe"></iframe> | ||
<script src="../resources/js-test.js"></script> | ||
<script src="../resources/wasm-builder.js"></script> | ||
<script src="./resources/load_wasm.js"></script> | ||
<script> | ||
description("Test that expected Wasm Module can be sent over window.parent.postMessage from iframe."); | ||
if (window.testRunner) | ||
testRunner.waitUntilDone(); | ||
|
||
function finish(value) { | ||
shouldBe(() => value, () => 35010); | ||
|
||
if (window.testRunner) | ||
testRunner.notifyDone(); | ||
} | ||
|
||
var run = async function () { | ||
try { | ||
window.addEventListener("message", (answer) => finish(answer.data), false); | ||
var mod = await createWasmModule(); | ||
var iframe = document.getElementById("iframe").contentWindow; | ||
iframe.postMessage(mod, '*'); | ||
} catch (e) { | ||
console.log('error:', e); | ||
} | ||
}; | ||
|
||
setTimeout(run); | ||
</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
@@ -0,0 +1,10 @@ | ||
Test that expected Wasm Module can be sent over iframe.postMessage. | ||
|
||
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". | ||
|
||
|
||
PASS successfullyParsed is true | ||
|
||
TEST COMPLETE | ||
PASS () => value is 35010 | ||
|
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
@@ -0,0 +1,30 @@ | ||
<!DOCTYPE html> | ||
<iframe src="./resources/frame.html" id="iframe"></iframe> | ||
<script src="../resources/js-test.js"></script> | ||
<script src="../resources/wasm-builder.js"></script> | ||
<script src="./resources/load_wasm.js"></script> | ||
<script> | ||
description("Test that expected Wasm Module can be sent over iframe.postMessage."); | ||
if (window.testRunner) | ||
testRunner.waitUntilDone(); | ||
|
||
function finish(value) { | ||
shouldBe(() => value, () => 35010); | ||
|
||
if (window.testRunner) | ||
testRunner.notifyDone(); | ||
} | ||
|
||
var run = async function () { | ||
try { | ||
window.addEventListener("message", (answer) => finish(answer.data), false); | ||
var mod = await createWasmModule(); | ||
var iframe = document.getElementById("iframe").contentWindow; | ||
iframe.postMessage(mod, '*'); | ||
} catch (e) { | ||
console.log('error:', e); | ||
} | ||
}; | ||
|
||
setTimeout(run); | ||
</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
@@ -0,0 +1,14 @@ | ||
<script> | ||
function listener(event) { | ||
var mod = event.data; | ||
try { | ||
var i = new WebAssembly.Instance(mod); | ||
var ans = i.exports.calc(5); | ||
window.parent.postMessage(ans, event.origin); | ||
} catch (e) { | ||
window.parent.postMessage(e, event.origin); | ||
} | ||
} | ||
|
||
addEventListener("message", listener, false) | ||
</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
@@ -0,0 +1,14 @@ | ||
<script> | ||
function listener(event) { | ||
var mod = event.data; | ||
try { | ||
var i = new WebAssembly.Instance(mod); | ||
var ans = i.exports.calc(5); | ||
event.source.postMessage(ans, event.origin); | ||
} catch (e) { | ||
event.source.postMessage(e, event.origin); | ||
} | ||
} | ||
|
||
addEventListener("message", listener, false) | ||
</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
@@ -0,0 +1,19 @@ | ||
function createWasmModule() { | ||
let builder = new Builder(); | ||
builder = builder.Type().End() | ||
.Function().End() | ||
.Export().Function("calc").End() | ||
.Code() | ||
.Function("calc", { params: ["i32"], ret: "i32" }) | ||
.GetLocal(0) | ||
.GetLocal(0) | ||
.I32Add(); | ||
|
||
const count = 7000; | ||
for (let i = 0; i < count; i++) { | ||
builder = builder.GetLocal(0).I32Add(); | ||
} | ||
builder = builder.Return().End().End(); | ||
|
||
return new WebAssembly.Module(builder.WebAssembly().get()); | ||
} |
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
@@ -0,0 +1,10 @@ | ||
Test that expected Wasm Module can be sent over window.postMessage. | ||
|
||
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". | ||
|
||
|
||
PASS successfullyParsed is true | ||
|
||
TEST COMPLETE | ||
PASS () => value is 7002 | ||
|
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
@@ -0,0 +1,31 @@ | ||
<!DOCTYPE html> | ||
<script src="../resources/js-test.js"></script> | ||
<script src="../resources/wasm-builder.js"></script> | ||
<script src="./resources/load_wasm.js"></script> | ||
<script> | ||
description("Test that expected Wasm Module can be sent over window.postMessage."); | ||
if (window.testRunner) | ||
testRunner.waitUntilDone(); | ||
|
||
window.addEventListener("message", (answer) => finish(answer.data), false); | ||
|
||
function finish(module) { | ||
var i = new WebAssembly.Instance(module); | ||
var value = i.exports.calc(1); | ||
shouldBe(() => value, () => 7002); | ||
|
||
if (window.testRunner) | ||
testRunner.notifyDone(); | ||
} | ||
|
||
var run = async function () { | ||
try { | ||
var mod = await createWasmModule(); | ||
window.postMessage(mod, '*'); | ||
} catch (e) { | ||
console.log('error:', e); | ||
} | ||
}; | ||
|
||
setTimeout(run); | ||
</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
@@ -1,6 +1,6 @@ | ||
<html> | ||
<head> | ||
<script src="../resources/wasm-builder.js"></script> | ||
<script src="../resources/js-test-pre.js"></script> | ||
</head> | ||
<body> | ||
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
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