mirror of
https://github.com/classilla/tenfourfox.git
synced 2024-07-06 03:29:01 +00:00
223 lines
5.6 KiB
HTML
223 lines
5.6 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<!--
|
|
https://bugzilla.mozilla.org/show_bug.cgi?id={1176712}
|
|
-->
|
|
<head>
|
|
<title>Test for Bug {1176712}</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>
|
|
<script type="application/javascript"
|
|
src="http://test/chrome/dom/activities/tests/mochi/common.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={1176712}">Mozilla Bug {1176712}</a>
|
|
<p id="display"></p>
|
|
<div id="content" style="display: none">
|
|
|
|
</div>
|
|
<pre id="test">
|
|
<script class="testbody" type="application/javascript;version=1.7">
|
|
|
|
var gGenerator = runTest();
|
|
|
|
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]]},
|
|
continueTest) });
|
|
}
|
|
|
|
SimpleTest.waitForExplicitFinish();
|
|
|
|
function installApp(aUrl) {
|
|
var request = navigator.mozApps.install(aUrl, { });
|
|
request.onerror = cbError;
|
|
request.onsuccess = continueTest;
|
|
return request;
|
|
}
|
|
|
|
function uninstall(aApp) {
|
|
info("Uninstalling " + (aApp ? aApp.manifestURL : "NO APP!!"));
|
|
var request = navigator.mozApps.mgmt.uninstall(aApp);
|
|
request.onerror = cbError;
|
|
request.onsuccess = continueTest;
|
|
}
|
|
|
|
var ActivityGlue = {
|
|
// nsISupports implementation.
|
|
QueryInterface: function(iid) {
|
|
if (iid.equals(Ci.nsISupports) ||
|
|
iid.equals(Ci.nsIFactory) ||
|
|
iid.equals(Ci.nsIActivityUIGlue)) {
|
|
return this;
|
|
}
|
|
|
|
throw Cr.NS_ERROR_NO_INTERFACE;
|
|
},
|
|
|
|
// nsIFactory implementation.
|
|
createInstance: function(outer, iid) {
|
|
return this.QueryInterface(iid);
|
|
},
|
|
|
|
// nsIActivityUIGlue implementation.
|
|
chooseActivity: function(aOptions, aActivities, aCallback) {
|
|
aCallback.handleEvent(Ci.nsIActivityUIGlueCallback.WEBAPPS_ACTIVITY,
|
|
aActivities.length == 1 ? 0 : -1);
|
|
}
|
|
};
|
|
|
|
var 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);
|
|
},
|
|
|
|
// nsISystemMessageGlue implementation.
|
|
openApp(pageURL, manifestURL, type, target, showApp, onlyShowApp, extra) {
|
|
}
|
|
};
|
|
|
|
registerComponent(ActivityGlue,
|
|
"Activity Glue",
|
|
"@mozilla.org/dom/activities/ui-glue;1",
|
|
ACTIVITY_GLUE_CID);
|
|
|
|
registerComponent(SystemMessageGlue,
|
|
"System Message Glue",
|
|
"@mozilla.org/dom/messages/system-message-glue;1",
|
|
SYS_MSG_GLUE_CID);
|
|
|
|
function finish() {
|
|
unregisterComponent(ActivityGlue);
|
|
unregisterComponent(SystemMessageGlue);
|
|
SimpleTest.finish();
|
|
}
|
|
|
|
function continueTest() {
|
|
try {
|
|
gGenerator.next();
|
|
} catch (e if e instanceof StopIteration) {
|
|
finish();
|
|
}
|
|
}
|
|
|
|
function runTest() {
|
|
SpecialPowers.setAllAppsLaunchable(true);
|
|
|
|
SpecialPowers.autoConfirmAppInstall(continueTest);
|
|
yield undefined;
|
|
|
|
SpecialPowers.autoConfirmAppUninstall(continueTest);
|
|
yield undefined;
|
|
|
|
// Check how many apps we are starting with.
|
|
var request = navigator.mozApps.mgmt.getAll();
|
|
request.onerror = cbError;
|
|
request.onsuccess = continueTest;
|
|
yield undefined;
|
|
var initialAppsCount = request.result.length;
|
|
info("Starting with " + initialAppsCount + " apps installed.");
|
|
|
|
// Before app installed
|
|
|
|
var activity = new MozActivity({
|
|
name: "bug1176712",
|
|
data: {
|
|
type: "type1"
|
|
}
|
|
});
|
|
activity.onsuccess = unexpectedSuccess("Shouldn't launch unregistered activity");
|
|
activity.onerror = () => {
|
|
ok(activity.error.name == "NO_PROVIDER", "Expected NO_PROVIDER");
|
|
continueTest();
|
|
};
|
|
yield undefined;
|
|
|
|
var activity = new MozActivity({
|
|
name: "bug1176712",
|
|
data: {
|
|
type: "type2"
|
|
}
|
|
});
|
|
activity.onsuccess = unexpectedSuccess("Shouldn't launch unregistered activity");
|
|
activity.onerror = () => {
|
|
ok(activity.error.name == "NO_PROVIDER", "Expected NO_PROVIDER");
|
|
continueTest();
|
|
};
|
|
yield undefined;
|
|
|
|
var request = installApp(gRootUrl + "manifest.webapp");
|
|
yield undefined;
|
|
var app = request.result;
|
|
ok(app, "App installed");
|
|
|
|
// After app installed
|
|
|
|
var activity = new MozActivity({
|
|
name: "bug1176712",
|
|
data: {
|
|
type: "type1"
|
|
}
|
|
});
|
|
activity.onsuccess = function() {
|
|
ok(true, "Activity launch succeed");
|
|
continueTest();
|
|
}
|
|
activity.onerror = cbError;
|
|
yield undefined;
|
|
|
|
var activity = new MozActivity({
|
|
name: "bug1176712",
|
|
data: {
|
|
type: "type2"
|
|
}
|
|
});
|
|
activity.onsuccess = function() {
|
|
ok(true, "Activity launch succeed");
|
|
continueTest();
|
|
}
|
|
activity.onerror = cbError;
|
|
yield undefined;
|
|
|
|
// Cleanup
|
|
uninstall(app);
|
|
yield undefined;
|
|
|
|
// Check that we restored the app registry.
|
|
request = navigator.mozApps.mgmt.getAll();
|
|
request.onerror = cbError;
|
|
request.onsuccess = continueTest;
|
|
yield undefined;
|
|
|
|
is(request.result.length, initialAppsCount, "All apps are uninstalled.");
|
|
}
|
|
|
|
addLoadEvent(go);
|
|
|
|
</script>
|
|
</pre>
|
|
</body>
|
|
</html>
|