зеркало из https://github.com/mozilla/gecko-dev.git
172 строки
6.0 KiB
HTML
172 строки
6.0 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() { },
|
|
__exposedProps__: { preventDefault: 'r' }
|
|
});
|
|
}
|
|
|
|
function iframeScriptSecond() {
|
|
let isMainProcess = content.wrappedJSObject.SpecialPowers.isMainProcess();
|
|
|
|
sendAsyncMessage("test:indexedDB:ipcProcessType",
|
|
{ isMainProcess: isMainProcess });
|
|
|
|
let TestRunner = content.wrappedJSObject.TestRunner;
|
|
|
|
let oldComplete = TestRunner.onComplete;
|
|
|
|
TestRunner.onComplete = function() {
|
|
TestRunner.onComplete = oldComplete;
|
|
|
|
sendAsyncMessage("test:indexedDB:ipcTestComplete");
|
|
|
|
if (oldComplete) {
|
|
oldComplete();
|
|
}
|
|
};
|
|
|
|
TestRunner.structuredLogger._dumpMessage = function(msg) {
|
|
sendAsyncMessage("test:indexedDB:ipcTestMessage", { msg: msg });
|
|
}
|
|
}
|
|
|
|
let seenTestMessage = false;
|
|
|
|
let VALID_ACTIONS = ['suite_start', 'suite_end', 'test_start', 'test_end', 'test_status', 'process_output', 'log'];
|
|
function validStructuredMessage(message) {
|
|
return message.action !== undefined && VALID_ACTIONS.indexOf(message.action) >= 0;
|
|
}
|
|
function onTestMessage(data) {
|
|
seenTestMessage = true;
|
|
let message = SpecialPowers.wrap(data).data.msg;
|
|
|
|
if (validStructuredMessage(message)) {
|
|
switch (message.action) {
|
|
case "test_status":
|
|
ok(message.expected === undefined, message.subtest, message.message);
|
|
break;
|
|
case "test_end":
|
|
ok(message.expected === undefined, message.test, message.message);
|
|
break;
|
|
case "log":
|
|
info(message.message);
|
|
break;
|
|
default:
|
|
// nothing
|
|
}
|
|
}
|
|
}
|
|
|
|
let usingChildProcess = false;
|
|
|
|
function onProcessType(data) {
|
|
let isMainProcess = SpecialPowers.wrap(data).data.isMainProcess;
|
|
usingChildProcess = !isMainProcess;
|
|
}
|
|
|
|
function onTestComplete() {
|
|
is(usingChildProcess, true, "Expecting to run in child process");
|
|
is(seenTestMessage, true, "Expecting to receive messages from child");
|
|
SpecialPowers.removePermission("browser", window.location.href);
|
|
SimpleTest.executeSoon(function () { SimpleTest.finish(); });
|
|
}
|
|
|
|
function runTests() {
|
|
let iframe = document.createElement("iframe");
|
|
SpecialPowers.wrap(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(SpecialPowers.Components);
|
|
|
|
let spObserver =
|
|
comp.classes["@mozilla.org/special-powers-observer;1"]
|
|
.getService(comp.interfaces.nsIMessageListener);
|
|
|
|
mm.addMessageListener("SPPrefService", spObserver);
|
|
mm.addMessageListener("SPProcessCrashService", spObserver);
|
|
mm.addMessageListener("SPPingService", spObserver);
|
|
mm.addMessageListener("SpecialPowers.Quit", spObserver);
|
|
mm.addMessageListener("SPPermissionManager", spObserver);
|
|
mm.addMessageListener("SPObserverService", spObserver);
|
|
|
|
mm.addMessageListener("test:indexedDB:ipcTestMessage", onTestMessage);
|
|
mm.addMessageListener("test:indexedDB:ipcProcessType", onProcessType);
|
|
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() {
|
|
SpecialPowers.addPermission("browser", true, document);
|
|
SpecialPowers.pushPrefEnv({
|
|
"set": [
|
|
// TODO: remove this as part of bug 820712
|
|
["network.disable.ipc.security", true],
|
|
|
|
["dom.ipc.browser_frames.oop_by_default", true],
|
|
["dom.mozBrowserFramesEnabled", true]
|
|
]
|
|
}, runTests);
|
|
});
|
|
</script>
|
|
</body>
|
|
</html>
|