mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
f47e2a9937
--HG-- rename : content/base/public/nsIFrameMessageManager.idl => content/base/public/nsIMessageManager.idl
153 lines
4.8 KiB
HTML
153 lines
4.8 KiB
HTML
<!DOCTYPE HTML>
|
|
<html>
|
|
<head>
|
|
<title>Test for OOP DeviceStorage</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();
|
|
|
|
function iframeScriptFirst() {
|
|
content.wrappedJSObject.RunSet.reloadAndRunAll({
|
|
preventDefault: function() { },
|
|
__exposedProps__: { preventDefault: 'r' }
|
|
});
|
|
}
|
|
|
|
function iframeScriptSecond() {
|
|
let TestRunner = content.wrappedJSObject.TestRunner;
|
|
|
|
let oldComplete = TestRunner.onComplete;
|
|
|
|
TestRunner.onComplete = function() {
|
|
TestRunner.onComplete = oldComplete;
|
|
|
|
sendAsyncMessage("test:DeviceStorage:ipcTestComplete", {
|
|
result: JSON.stringify(TestRunner._failedTests)
|
|
});
|
|
|
|
if (oldComplete) {
|
|
oldComplete();
|
|
}
|
|
};
|
|
|
|
let oldLog = TestRunner.log;
|
|
TestRunner.log = function(msg) {
|
|
sendAsyncMessage("test:DeviceStorage:ipcTestMessage", { msg: msg });
|
|
}
|
|
}
|
|
|
|
let regex = /^(TEST-PASS|TEST-UNEXPECTED-PASS|TEST-KNOWN-FAIL|TEST-UNEXPECTED-FAIL|TEST-DEBUG-INFO) \| ([^\|]+) \|(.*)/;
|
|
|
|
function onTestMessage(data) {
|
|
let message = SpecialPowers.wrap(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() {
|
|
let comp = SpecialPowers.wrap(Components);
|
|
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.nsIMessageListener);
|
|
|
|
mm.addMessageListener("SPPrefService", spObserver);
|
|
mm.addMessageListener("SPProcessCrashService", spObserver);
|
|
mm.addMessageListener("SPPingService", spObserver);
|
|
mm.addMessageListener("SpecialPowers.Quit", spObserver);
|
|
mm.addMessageListener("SPPermissionManager", spObserver);
|
|
|
|
mm.addMessageListener("test:DeviceStorage:ipcTestMessage", onTestMessage);
|
|
mm.addMessageListener("test:DeviceStorage: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": [
|
|
|
|
["device.storage.enabled", true],
|
|
["device.storage.testing", true],
|
|
["device.storage.prompt.testing", true],
|
|
|
|
["dom.ipc.browser_frames.oop_by_default", true],
|
|
["dom.mozBrowserFramesEnabled", true],
|
|
["browser.pageThumbs.enabled", false]
|
|
]
|
|
}, runTests);
|
|
});
|
|
|
|
</script>
|
|
</body>
|
|
</html>
|