mirror of
https://github.com/roytam1/palemoon27.git
synced 2026-05-26 14:18:48 +00:00
fe0509a62e
- 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)
233 lines
7.0 KiB
HTML
233 lines
7.0 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<title>System messages registration tests</title>
|
|
<script type="application/javascript"
|
|
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
|
|
<script type="application/javascript"
|
|
src="chrome://mochikit/content/chrome-harness.js"></script>
|
|
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/>
|
|
</head>
|
|
<body>
|
|
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1162281}">Mozilla Bug {1162281}</a>
|
|
<p id="display"></p>
|
|
<div id="content" style="display: none">
|
|
|
|
</div>
|
|
<pre id="test">
|
|
<script class="testbody" type="application/javascript;version=1.7">
|
|
|
|
const { classes: Cc, interfaces: Ci, utils: Cu, results: Cr } = Components;
|
|
|
|
Cu.import("resource://gre/modules/Services.jsm");
|
|
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
|
|
|
// We need to keep the same CID as the one used on activities tests.
|
|
// Check https://bugzilla.mozilla.org/show_bug.cgi?id=1176712#c13
|
|
const SYS_MSG_GLUE_CID = Components.ID("{b0b6b9af-bc4e-4200-bffe-fb7691065ec9}");
|
|
|
|
XPCOMUtils.defineLazyGetter(this, "messenger", () => {
|
|
return Cc["@mozilla.org/system-message-internal;1"]
|
|
.getService(Ci.nsISystemMessagesInternal);
|
|
});
|
|
|
|
let gRootUrl = "http://test/chrome/dom/messages/test/";
|
|
let validAppUrl = gRootUrl + "manifest.webapp";
|
|
let invalidAppUrl = gRootUrl + "invalid_manifest.webapp";
|
|
let validApp;
|
|
let initialAppsCount;
|
|
let index = 0;
|
|
|
|
SimpleTest.waitForExplicitFinish();
|
|
|
|
function go() {
|
|
SpecialPowers.pushPermissions(
|
|
[{ "type": "webapps-manage", "allow": 1, "context": document },
|
|
{ "type": "browser", "allow": 1, "context": document },
|
|
{ "type": "embed-apps", "allow": 1, "context": document }],
|
|
function() {
|
|
SpecialPowers.pushPrefEnv(
|
|
{'set': [["dom.mozBrowserFramesEnabled", true],
|
|
["dom.sysmsg.enabled", true]]},
|
|
next) });
|
|
}
|
|
|
|
function finish() {
|
|
unregisterComponent(SystemMessageGlue);
|
|
SimpleTest.finish();
|
|
}
|
|
|
|
function next() {
|
|
info("Step " + index);
|
|
if (index >= steps.length) {
|
|
ok(false, "Shouldn't get here!");
|
|
return;
|
|
}
|
|
try {
|
|
let i = index++;
|
|
steps[i]();
|
|
} catch(ex) {
|
|
ok(false, "Caught exception", ex);
|
|
}
|
|
}
|
|
|
|
function cbError(aEvent) {
|
|
ok(false, "Error callback invoked " +
|
|
aEvent.target.error.name + " " + aEvent.target.error.message);
|
|
finish();
|
|
}
|
|
|
|
function uninstall(aApp) {
|
|
info("Uninstalling " + (aApp ? aApp.manifestURL : "NO APP!!"));
|
|
}
|
|
|
|
function registerComponent(aObject, aDescription, aContract) {
|
|
info("Registering " + SYS_MSG_GLUE_CID);
|
|
|
|
let componentManager =
|
|
Components.manager.QueryInterface(Ci.nsIComponentRegistrar);
|
|
componentManager.registerFactory(SYS_MSG_GLUE_CID, aDescription, aContract, aObject);
|
|
}
|
|
|
|
function unregisterComponent(aObject) {
|
|
info("Unregistering " + SYS_MSG_GLUE_CID);
|
|
let componentManager =
|
|
Components.manager.QueryInterface(Ci.nsIComponentRegistrar);
|
|
componentManager.unregisterFactory(SYS_MSG_GLUE_CID, aObject);
|
|
}
|
|
|
|
let SystemMessageGlue = {
|
|
// nsISupports implementation.
|
|
QueryInterface: function(iid) {
|
|
if (iid.equals(Ci.nsISupports) ||
|
|
iid.equals(Ci.nsIFactory) ||
|
|
iid.equals(Ci.nsISystemMessageGlue)) {
|
|
return this;
|
|
}
|
|
|
|
throw Cr.NS_ERROR_NO_INTERFACE;
|
|
},
|
|
|
|
// nsIFactory implementation.
|
|
createInstance: function(outer, iid) {
|
|
return this.QueryInterface(iid);
|
|
},
|
|
|
|
_lastManifestURL: null,
|
|
|
|
// nsISystemMessageGlue implementation.
|
|
openApp(pageURL, manifestURL, type, target, showApp, onlyShowApp, extra) {
|
|
this._lastManifestURL = manifestURL;
|
|
}
|
|
};
|
|
|
|
registerComponent(SystemMessageGlue,
|
|
"System Message Glue",
|
|
"@mozilla.org/dom/messages/system-message-glue;1");
|
|
|
|
function testBroadcastMessage(aMessage, aExpectedManifestURL, aMsg) {
|
|
SystemMessageGlue._lastManifestURL = null;
|
|
messenger.broadcastMessage(aMessage, {}, {})
|
|
.then(() => {
|
|
is(SystemMessageGlue._lastManifestURL, aExpectedManifestURL, aMsg);
|
|
next();
|
|
})
|
|
.catch(cbError);
|
|
}
|
|
|
|
/**
|
|
* TESTS
|
|
*/
|
|
let steps = [() => {
|
|
Services.obs.notifyObservers(null, "webapps-registry-ready", null);
|
|
SpecialPowers.setAllAppsLaunchable(true);
|
|
SpecialPowers.autoConfirmAppInstall(next);
|
|
}, () => {
|
|
SpecialPowers.autoConfirmAppUninstall(next);
|
|
}, () => {
|
|
// Check how many apps we are starting with.
|
|
let request = navigator.mozApps.mgmt.getAll();
|
|
request.onerror = cbError;
|
|
request.onsuccess = () => {
|
|
initialAppsCount = request.result.length;
|
|
info("Starting with " + initialAppsCount + " apps installed.");
|
|
next();
|
|
};
|
|
}, () => {
|
|
// We still have not installed any app handling dummy-system-message.
|
|
testBroadcastMessage("dummy-system-message", null,
|
|
"no system message should be sent");
|
|
}, () => {
|
|
testBroadcastMessage("dummy-system-message2", null,
|
|
"no system message should be sent");
|
|
}, () => {
|
|
navigator.mozApps.mgmt.oninstall = () => {
|
|
validApp = request.result;
|
|
next();
|
|
};
|
|
let request = navigator.mozApps.install(validAppUrl, { });
|
|
request.error = cbError;
|
|
request.onsuccess = () => {
|
|
validApp = request.result;
|
|
};
|
|
}, () => {
|
|
// Installing the test app should register the system message.
|
|
testBroadcastMessage("dummy-system-message", validAppUrl,
|
|
"system message should be sent");
|
|
}, () => {
|
|
// Installing the test app should register the system message.
|
|
testBroadcastMessage("dummy-system-message2", validAppUrl,
|
|
"system message should be sent");
|
|
}, () => {
|
|
navigator.mozApps.mgmt.onuninstall = () => {
|
|
validApp = null;
|
|
next();
|
|
};
|
|
let request = navigator.mozApps.mgmt.uninstall(validApp);
|
|
request.onerror = cbError;
|
|
}, () => {
|
|
// Uninstalling the app should unregister the system messages.
|
|
testBroadcastMessage("dummy-system-message", null,
|
|
"no system message should be sent");
|
|
}, () => {
|
|
// Uninstalling the app should unregister the system messages.
|
|
testBroadcastMessage("dummy-system-message2", null,
|
|
"no system message should be sent");
|
|
}, () => {
|
|
navigator.mozApps.mgmt.oninstall = () => {
|
|
validApp = request.result;
|
|
next();
|
|
};
|
|
let request = navigator.mozApps.install(invalidAppUrl, { });
|
|
request.onerror = () => {
|
|
ok(true, "should not install invalid app");
|
|
next();
|
|
};
|
|
request.onsuccess = () => {
|
|
ok(false, "should not install invalid app");
|
|
finish();
|
|
};
|
|
}, () => {
|
|
testBroadcastMessage("dummy-system-message", null,
|
|
"no system message should be sent");
|
|
}, () => {
|
|
testBroadcastMessage("dummy-system-message2", null,
|
|
"no system message should be sent");
|
|
}, () => {
|
|
// Check how many apps we are finishing with.
|
|
let request = navigator.mozApps.mgmt.getAll();
|
|
request.onerror = cbError;
|
|
request.onsuccess = () => {
|
|
info("Finishing with " + request.result.length + " apps installed.");
|
|
is(initialAppsCount, request.result.length, "All apps are uninstalled");
|
|
next();
|
|
};
|
|
}, finish];
|
|
|
|
addLoadEvent(go);
|
|
|
|
</script>
|
|
</pre>
|
|
</body>
|
|
</html>
|