<!DOCTYPE>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script id="myWorker" type="text/worker">
self.onmessage = function(e) {
var offscreenCanvas = e.data;
var offscreen2d = offscreenCanvas.getContext("2d");
self.postMessage("worker done");
};
</script>
<script>
function makeWorker() {
var blob = new Blob([document.getElementById("myWorker").textContent]);
return new Worker(URL.createObjectURL(blob));
}
// Regression test for crbug.com/663916
async_test(function(t) {
var canvas1 = document.createElement('canvas');
canvas1.width = canvas1.height = 10;
var offscreenCanvas1 = canvas1.transferControlToOffscreen();
var canvas2 = document.createElement('canvas');
canvas2.width = canvas2.height = 10;
var offscreenCanvas2 = canvas2.transferControlToOffscreen();
var worker1 = makeWorker();
var worker2 = makeWorker();
var returnedWorkerCounter = 0;
worker1.onmessage = worker2.onmessage = function (e) {
returnedWorkerCounter++;
if (returnedWorkerCounter == 2)
t.done();
};
worker1.postMessage(offscreenCanvas1, [offscreenCanvas1]);
worker2.postMessage(offscreenCanvas2, [offscreenCanvas2]);
}, "Having two canvas from two workers should not crash.");
</script>