gecko/dom/indexedDB/ipc/test_ipc.html
Benjamin Peterson d1064385b3 Bug 761723 - Save script sources to implement Function.prototype.toString. r=jorendorff,njn,jimb,jst,Ms2ger
--HG--
extra : rebase_source : de1b55647780a30f98fe84d29ee3cb4a437a3ece
2012-07-20 20:17:38 +02:00

170 lines
5.4 KiB
HTML

<!DOCTYPE HTML>
<html>
<head>
<title>Test for OOP IndexedDB</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<script type="application/javascript;version=1.7">
"use strict";
SimpleTest.waitForExplicitFinish();
// This isn't a single test, really... It runs the entirety of the IndexedDB
// tests. Each of those has a normal timeout handler, so there's no point in
// having a timeout here. I'm setting this really high just to avoid getting
// killed.
SimpleTest.requestLongerTimeout(100);
// Disable crash observers as it breaks later tests.
function iframeScriptFirst() {
SpecialPowers.prototype.registerProcessCrashObservers = function() { };
SpecialPowers.prototype.unregisterProcessCrashObservers = function() { };
content.wrappedJSObject.RunSet.reloadAndRunAll({
preventDefault: function() { }
});
}
function iframeScriptSecond() {
let TestRunner = content.wrappedJSObject.TestRunner;
let oldComplete = TestRunner.onComplete;
TestRunner.onComplete = function() {
TestRunner.onComplete = oldComplete;
sendAsyncMessage("test:indexedDB:ipcTestComplete", {
result: JSON.stringify(TestRunner._failedTests)
});
if (oldComplete) {
oldComplete();
}
};
let oldLog = TestRunner.log;
TestRunner.log = function(msg) {
sendAsyncMessage("test:indexedDB:ipcTestMessage", { msg: msg });
}
}
let regexString =
"^(TEST-PASS|TEST-UNEXPECTED-PASS|TEST-KNOWN-FAIL|TEST-UNEXPECTED-FAIL" +
"|TEST-DEBUG-INFO) \\| ([^\\|]+) \\|(.*)";
let regex = new RegExp(regexString);
function onTestMessage(data) {
let message = data.json.msg;
let match = regex.exec(message);
if (match) {
let state = match[1];
let details = match[2] + " | " + match[3];
switch (state) {
case "TEST-PASS":
case "TEST-KNOWN-FAIL":
ok(true, details);
break;
case "TEST-UNEXPECTED-FAIL":
case "TEST-UNEXPECTED-PASS":
ok(false, details);
break;
case "TEST-DEBUG-INFO":
default:
info(details);
}
}
}
function onTestComplete() {
ok(true, "Got test complete message");
SimpleTest.executeSoon(function () { SimpleTest.finish(); });
}
function runTests() {
let iframe = document.createElement("iframe");
iframe.mozbrowser = true;
iframe.id = "iframe";
iframe.style.width = "100%";
iframe.style.height = "1000px";
function iframeLoadSecond() {
ok(true, "Got second iframe load event.");
iframe.removeEventListener("mozbrowserloadend", iframeLoadSecond);
let mm = SpecialPowers.getBrowserFrameMessageManager(iframe);
mm.loadFrameScript("data:,(" + iframeScriptSecond.toString() + ")();",
false);
}
function iframeLoadFirst() {
ok(true, "Got first iframe load event.");
iframe.removeEventListener("mozbrowserloadend", iframeLoadFirst);
iframe.addEventListener("mozbrowserloadend", iframeLoadSecond);
let mm = SpecialPowers.getBrowserFrameMessageManager(iframe);
let comp = SpecialPowers.wrap(Components);
let spObserver =
comp.classes["@mozilla.org/special-powers-observer;1"]
.getService(comp.interfaces.nsIFrameMessageListener);
mm.addMessageListener("SPPrefService", spObserver);
mm.addMessageListener("SPProcessCrashService", spObserver);
mm.addMessageListener("SPPingService", spObserver);
mm.addMessageListener("SpecialPowers.Quit", spObserver);
mm.addMessageListener("SPPermissionManager", spObserver);
mm.addMessageListener("test:indexedDB:ipcTestMessage", onTestMessage);
mm.addMessageListener("test:indexedDB:ipcTestComplete", onTestComplete);
let specialPowersBase = "chrome://specialpowers/content/";
mm.loadFrameScript(specialPowersBase + "MozillaLogger.js", false);
mm.loadFrameScript(specialPowersBase + "specialpowersAPI.js", false);
mm.loadFrameScript(specialPowersBase + "specialpowers.js", false);
mm.loadFrameScript("data:,(" + iframeScriptFirst.toString() + ")();",
false);
}
iframe.addEventListener("mozbrowserloadend", iframeLoadFirst);
// Strip this filename and one directory level and then add "/test".
let href = window.location.href;
href = href.substring(0, href.lastIndexOf('/'));
href = href.substring(0, href.lastIndexOf('/'));
iframe.src = href + "/test?consoleLevel=INFO";
document.body.appendChild(iframe);
}
addEventListener("load", function() {
let whitelist;
try {
whitelist =
SpecialPowers.getCharPref("dom.mozBrowserFramesWhitelist") + ", ";
} catch (e) {
whitelist = "";
}
whitelist += window.location.protocol + "//" + window.location.host;
SpecialPowers.pushPrefEnv({
"set": [
["dom.ipc.browser_frames.oop_by_default", true],
["dom.mozBrowserFramesEnabled", true],
["dom.mozBrowserFramesWhitelist", whitelist],
["browser.pageThumbs.enabled", false]
]
}, runTests);
});
</script>
</body>
</html>