gecko-dev/dom/tests/mochitest/general/file_clonewrapper.html
Bobby Holley 24a1e4a8e1 Bug 1050340 - Fix up cloning test. r=gabor
This test currently assume that cloning a COW will fail. Once we always go over
security wrappers, this isn't true anymore, because COWs silently deny
disallowed property gets. So it makes sense to rewrite the test so that we can
see what actually makes it through the structured clones. Promises galore.

We also take out the buggy Blob/FileList stuff and replace it with ImageData,
which does a bonafide clone in NS_DOMWriteStructuredClone instead of the weird
pointer swapping we do in nsGlobalWindow.cpp (baku is in the process of cleaning
that up, but it's not done yet).
2014-08-18 14:18:40 -07:00

37 lines
985 B
HTML

<!doctype html>
<html>
<head>
<script type="application/javascript">
function waitForMessage() {
return new Promise(function(resolve) {
window.addEventListener('message', function l(evt) {
window.removeEventListener('message', l);
resolve(evt.data);
});
});
}
// Set up the objects for cloning.
function setup() {
window.testObject = { myNumber: 42,
myString: "hello",
myImageData: new ImageData(10, 10) };
}
// Called by the chrome parent window.
function tryToClone(obj, shouldSucceed, message) {
var success = false;
try { window.postMessage(obj, '*'); success = true; }
catch (e) { message = message + ' (threw: ' + e.message + ')'; }
is(success, shouldSucceed, message);
return (success && shouldSucceed) ? waitForMessage() : Promise.resolve();
}
</script>
</head>
<body onload="setup()">
<input id="fileinput" type="file"></input>
</body>
</html>