Files
palemoon27/dom/messages/test/test_hasPendingMessage.html
T
roytam1 fe0509a62e import changes from `dev' branch of rmottola/Arctic-Fox:
- Bug 904479 - Added createPromiseWithId() that returns id of resolver r=kanru,nsm (2ac672d882)
- Bug 1166580 - Disable mozHasPendingMessage tests on non-browser platform. r=me (03c689964b)
- Bug 1162281 - Invalid system message handler in an App Manifest can break the entire system. r=fabrice (e192a95f9c)
- Bug 1198988 - Turn off some useless dump() calls r=ferjm (34fc83b236)
- Bug 1164498: Remove |DispatchBluetoothReply|, r=btian (6143335efa)
- Bug 1001757 - Add ability to store core apps outside of profile on desktop b2g; r=fabrice (f6b605e7aa)
- Bug 1155245 - Set the app status correctly for hosted certified apps in developer mode. r=fabrice (131178b80e)
- Bug 1179052 - Add some raptor markers to b2g gecko startup r=gwagner (222256fad8)
- Bug 1163904 - handle -url command line argument. r=fabrice (ee61af1ff9)
- Bug 1167275 - JS error in shell.js handleCmdLine() r=me (32e75c604f)
- Bug 1167197 - Fix GMPProvider on Android r=cpearce Bug 1181209 - Make changes to Gecko needed for b2gdroid to boot. r=fabrice (b35d3a372f)
- Bug 1158544 - Remove FTPChannelChild::mWasOpened and make the base class mWasOpened protected; r=mcmanus (9111e1bc00)
- Bug 1171716 - Part 2: Use NS_ReleaseOnMainThread in nsBaseChannel. r=froydnj (f138124f14)
- partial of Bug 1177175 - Add a UITour target inside the TP panel. (603cc719b3)
- Bug 1175545 - Dont process alt-svc on 421 r=hurley (ad0f2f6e91)
- Bug 1191291 - convert nsHttpChannel::RetargetDeliveryTo warning to log r=michal.novotny (b9c6003df8)
- Bug 1182487 - Don't try to write to HTTP cache entry in nsHttpChannel when entry is open for reading only. r=michal (b36d7014a0)
- Bug 1173069 - Don't accumulate the cache hit telemetry for intercepted channels; r=mayhemer,jdm (aaed79183d)
- Bug 1208755 HttpBaseChannel::ShouldIntercept() should not assume every channel has a LoadInfo. r=ckerschb (d55be94901)
- Bug 1201229 - Return an empty string for a header when an error occurs; r=dragana (256d0462c8)
- Bug 1048048 - add preload content policy types - web platform test updates (r=dveditz) (baa1004dd6)
- Bug 1048048 - add preload content policy types - csp changes (r=dveditz) (17914dadba)
- Bug 1048048 - add preload content policy types for stylesheets (r=cam) (29af13263a)
- Bug 1048048 - add preload content policy types (r=ehsan) (f58a32d51b)
- Bug 1201747 - Don't inspect the subject principal in StorageAllowedForPrincipal. r=mystor (4f2c100882)
- Bug 1176829 - Remove custom elements base element queue. r=smaug (03a520c13d)
- Bug 1176829 follow-up, finish removing unused member to fix bustage. CLOSED TREE (29c6150af8)
- Bug 1179909: Build fix. r=me CLOSED TREE (40e3bdb971)
- Bug 1188932 - Allow the User-Agent header to be explicitly set by requests, r=bkelly, r=jgraham (37aacbd37d)
2022-04-01 23:06:55 +08:00

111 lines
4.9 KiB
HTML

<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Test navigator.mozHasPendingMessage</title>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="chrome://global/skin"/>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/>
<script type="application/javascript;version=1.8">
"use strict";
const { utils: Cu, interfaces: Ci, classes: Cc } = Components;
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
SimpleTest.waitForExplicitFinish();
function expectAlert(iframe, message, assertion) {
return new Promise((resolve, reject) => {
iframe.addEventListener("mozbrowsershowmodalprompt", function cb(e) {
iframe.removeEventListener("mozbrowsershowmodalprompt", cb);
is(e.detail.message, message, assertion);
resolve();
});
});
}
function runTest(isRemote) {
return new Promise((finish, reject) => {
let testURL = "http://mochi.test:8888/chrome/dom/messages/test/file_hasPendingMessage.html";
let manifestURL = "http://example.org/manifest.webapp";
let testURI = Services.io.newURI(testURL, null, null);
let manifestURI = Services.io.newURI(manifestURL, null, null);
let body = document.getElementsByTagName("body")[0];
let test_frame = document.createElement("iframe");
test_frame.setAttribute("mozbrowser", "true");
test_frame.setAttribute("remote", isRemote);
test_frame.setAttribute("src", testURL);
test_frame.setAttribute("mozapp", manifestURL);
// Step 0. Register Page or install app
let smi = Cc["@mozilla.org/system-message-internal;1"]
.getService(Ci.nsISystemMessagesInternal);
smi.registerPage("dummy-system-message", testURI, manifestURI);
smi.registerPage("dummy-system-message2", testURI, manifestURI);
// XXX lie to SystemMessageInternal to unblock sendMessage
Services.obs.notifyObservers(null, "webapps-registry-ready", null);
// Step 1. Send system message
smi.sendMessage("dummy-system-message", null, testURI, manifestURI);
// Step 2. Run app & check hasPendingMessages
body.appendChild(test_frame);
expectAlert(test_frame, "before load", "hasPendingMessages before load").then(() => {
// Step 3. Wait load & check hasPendingMessages
return expectAlert(test_frame, "load", "hasPendingMessages after load");
}).then(() => {
// Step 4. Send second system message
smi.sendMessage("dummy-system-message2", null, testURI, manifestURI);
// Step 5. Check hasPendingMessages
test_frame.src = testURL + "#checkPendingMessages";
return expectAlert(test_frame, "after launch", "hasPendingMessages after app launch");
}).then(() => {
// Step 6. mozSetMessageHandler
test_frame.src = testURL + "#setMessageHandler";
return expectAlert(test_frame, "handle message", "message handled");
}).then(() => {
// Setp 7. Check hasPendingMessages
return expectAlert(test_frame, "no hasPendingMessages",
"no hasPendingMessages after mozSetMessageHandler");
}).then(() => {
// Step 6. mozSetMessageHandler2
test_frame.src = testURL + "#setMessageHandler2";
return expectAlert(test_frame, "handle message", "message handled");
}).then(() => {
// Step 7. Check hasPendingMessages2
return expectAlert(test_frame, "no hasPendingMessages",
"no hasPendingMessages after mozSetMessageHandler");
}).then(() => {
// Be nice with the rest of the tests and clean up what we registered.
let appsSvc = Cc["@mozilla.org/AppsService;1"]
.getService(Ci.nsIAppsService);
let appId = appsSvc.getAppLocalIdByManifestURL(manifestURL);
let subject = {
appId: appId,
browserOnly: false,
QueryInterface: XPCOMUtils.generateQI([
Ci.mozIApplicationClearPrivateDataParams
])
};
Services.obs.notifyObservers(subject, "webapps-clear-data", null);
test_frame.remove();
finish();
});
});
}
window.addEventListener("load", function onLoad() {
window.removeEventListener("load", onLoad);
SpecialPowers.pushPrefEnv({'set': [["dom.mozBrowserFramesEnabled", true],
["dom.sysmsg.enabled", true]]}, () => {
runTest(/* isRemote= */false)
.then(() => runTest(/* isRemote= */true))
.then(SimpleTest.finish);
});
});
</script>
</head>
<body>
</body>
</html>