Bug 1130570 - Fix tests to use iframe to work on b2g. r=nsm

--HG--
extra : rebase_source : 88757a9f40a1b6c7e0dcd71afceee778c8b2e21a
This commit is contained in:
Andrea Marchesini 2015-02-12 15:10:11 -08:00
parent 59c94c2ff2
commit 3a3e06fb32
2 changed files with 14 additions and 5 deletions

View File

@ -17,11 +17,11 @@
// Make sure to use good, unique messages, since the actual expression will not show up in test results.
function my_ok(result, msg) {
window.opener.postMessage({status: "ok", result: result, message: msg}, "*");
parent.postMessage({status: "ok", result: result, message: msg}, "*");
}
function finish() {
window.opener.postMessage({status: "done"}, "*");
parent.postMessage({status: "done"}, "*");
}
navigator.serviceWorker.ready.then(function(swr) {

View File

@ -15,6 +15,9 @@
<pre id="test"></pre>
<script class="testbody" type="text/javascript">
var content;
var iframe;
function simpleRegister() {
// We use the control scope for the less specific registration. The window will register a worker on controller/
return navigator.serviceWorker.register("worker.js", { scope: "./control" });
@ -27,17 +30,23 @@
ok(e.data.result, e.data.message);
} else if (e.data.status == "done") {
window.onmessage = null;
w.close();
content.removeChild(iframe);
resolve();
}
}
});
var w = window.open("controller/index.html");
content = document.getElementById("content");
ok(content, "Parent exists.");
iframe = document.createElement("iframe");
iframe.setAttribute('src', "controller/index.html");
content.appendChild(iframe);
return p;
}
// This document just flips the prefs and opens the window for the actual test.
// This document just flips the prefs and opens the iframe for the actual test.
function runTest() {
simpleRegister()
.then(testController)