зеркало из https://github.com/mozilla/gecko-dev.git
bug 785545 - unrefactor mozApps tests for maximum readability/reliability; r=fabrice
This commit is contained in:
Родитель
bfcb73a0c2
Коммит
b4fdf2f847
|
@ -14,17 +14,18 @@ DIRS = \
|
|||
apps \
|
||||
$(NULL)
|
||||
|
||||
MOCHITEST_CHROME_FILES = \
|
||||
MOCHITEST_CHROME_FILES = \
|
||||
bug_765063.xul \
|
||||
cross_origin.html \
|
||||
head.js \
|
||||
test_bug_765063.xul \
|
||||
test_cross_origin.xul \
|
||||
test_install_app.xul \
|
||||
test_list_api.xul \
|
||||
test_install_errors.xul \
|
||||
test_cross_domain.xul \
|
||||
test_install_utf8.xul \
|
||||
test_install_receipts.xul \
|
||||
test_getNotInstalled.xul \
|
||||
jshelper.js \
|
||||
apphelper.js \
|
||||
$(NULL)
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
|
|
@ -1,113 +0,0 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
const MODE_READONLY = 0x01;
|
||||
const PERMS_FILE = 0644;
|
||||
|
||||
var popupNotifications = getPopupNotifications(window.top);
|
||||
|
||||
var event_listener_loaded = {};
|
||||
|
||||
Components.utils.import("resource://gre/modules/Services.jsm");
|
||||
Components.utils.import("resource://gre/modules/Webapps.jsm");
|
||||
|
||||
Components.classes["@mozilla.org/permissionmanager;1"]
|
||||
.getService(Components.interfaces.nsIPermissionManager)
|
||||
.addFromPrincipal(window.document.nodePrincipal,
|
||||
"webapps-manage",
|
||||
Components.interfaces.nsIPermissionManager.ALLOW_ACTION);
|
||||
|
||||
SpecialPowers.addPermission("webapps-manage", true, "http://mochi.test:8888");
|
||||
|
||||
SpecialPowers.setBoolPref('dom.mozBrowserFramesEnabled', true);
|
||||
SpecialPowers.setBoolPref('browser.mozApps.installer.dry_run', true);
|
||||
SpecialPowers.setBoolPref("dom.mozBrowserFramesWhitelist", "http://www.example.com");
|
||||
|
||||
let originalAAL = DOMApplicationRegistry.allAppsLaunchable;
|
||||
DOMApplicationRegistry.allAppsLaunchable = true;
|
||||
|
||||
var triggered = false;
|
||||
|
||||
function iterateMethods(label, root, suppress) {
|
||||
var arr = [];
|
||||
for (var f in root) {
|
||||
if (suppress && suppress.indexOf(f) != -1)
|
||||
continue;
|
||||
if (typeof root[f] === 'function')
|
||||
arr.push(label + f);
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
|
||||
function getPopupNotifications(aWindow) {
|
||||
var Ci = Components.interfaces;
|
||||
var chromeWin = aWindow.QueryInterface(Ci.nsIInterfaceRequestor)
|
||||
.getInterface(Ci.nsIWebNavigation)
|
||||
.QueryInterface(Ci.nsIDocShell)
|
||||
.chromeEventHandler.ownerDocument.defaultView;
|
||||
|
||||
return chromeWin.PopupNotifications;
|
||||
}
|
||||
|
||||
function triggerMainCommand(popup) {
|
||||
var notifications = popup.childNodes;
|
||||
ok(notifications.length > 0, "at least one notification displayed");
|
||||
var notification = notifications[0];
|
||||
debug("triggering command: " + notification.getAttribute("buttonlabel"));
|
||||
|
||||
notification.button.doCommand();
|
||||
}
|
||||
|
||||
function mainCommand() {
|
||||
triggerMainCommand(this);
|
||||
}
|
||||
|
||||
function popup_listener() {
|
||||
debug("here in popup listener");
|
||||
popupNotifications.panel.addEventListener("popupshown", mainCommand, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads text from a file and returns the string.
|
||||
*
|
||||
* @param aFile
|
||||
* The file to read from.
|
||||
* @return The string of text read from the file.
|
||||
*/
|
||||
function readFile(aFile) {
|
||||
|
||||
var file = Components.classes["@mozilla.org/file/directory_service;1"].
|
||||
getService(Components.interfaces.nsIProperties).
|
||||
get("CurWorkD", Components.interfaces.nsILocalFile);
|
||||
var fis = Components.classes["@mozilla.org/network/file-input-stream;1"].
|
||||
createInstance(Components.interfaces.nsIFileInputStream);
|
||||
var paths = "chrome/dom/tests/mochitest/webapps" + aFile;
|
||||
var split = paths.split("/");
|
||||
var sis = Components.classes["@mozilla.org/scriptableinputstream;1"].
|
||||
createInstance(Components.interfaces.nsIScriptableInputStream);
|
||||
var utf8Converter = Components.classes["@mozilla.org/intl/utf8converterservice;1"].
|
||||
getService(Components.interfaces.nsIUTF8ConverterService);
|
||||
|
||||
for(var i = 0; i < split.length; ++i) {
|
||||
file.append(split[i]);
|
||||
}
|
||||
fis.init(file, MODE_READONLY, PERMS_FILE, 0);
|
||||
sis.init(fis);
|
||||
var text = sis.read(sis.available());
|
||||
text = utf8Converter.convertURISpecToUTF8 (text, "UTF-8");
|
||||
sis.close();
|
||||
debug (text);
|
||||
return text;
|
||||
}
|
||||
|
||||
function getOrigin(url) {
|
||||
return Services.io.newURI(url, null, null).prePath;
|
||||
}
|
||||
|
||||
function tearDown() {
|
||||
debug("in " + arguments.callee.name);
|
||||
popupNotifications.panel.removeEventListener("popupshown", mainCommand, false);
|
||||
SpecialPowers.clearUserPref('browser.mozApps.installer.dry_run');
|
||||
DOMApplicationRegistry.allAppsLaunchable = originalAAL;
|
||||
}
|
||||
|
|
@ -11,12 +11,8 @@ relativesrcdir = @relativesrcdir@
|
|||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
MOCHITEST_CHROME_FILES = \
|
||||
bug_765063.xul \
|
||||
include.html \
|
||||
wild_crazy.webapp \
|
||||
wild_crazy.webapp^headers^ \
|
||||
super_crazy.webapp \
|
||||
super_crazy.webapp^headers^ \
|
||||
basic.webapp \
|
||||
basic.webapp^headers^ \
|
||||
missing_required_field.webapp \
|
||||
missing_required_field.webapp^headers^ \
|
||||
json_syntax_error.webapp \
|
||||
|
@ -24,8 +20,8 @@ MOCHITEST_CHROME_FILES = \
|
|||
no_delegated_install.webapp \
|
||||
no_delegated_install.webapp^headers^ \
|
||||
bad_content_type.webapp \
|
||||
manifest_with_bom.webapp \
|
||||
manifest_with_bom.webapp^headers^ \
|
||||
utf8.webapp \
|
||||
utf8.webapp^headers^ \
|
||||
$(NULL)
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
"name": "Basic App",
|
||||
"installs_allowed_from": ["*"]
|
||||
}
|
|
@ -1,92 +0,0 @@
|
|||
<!-- Any copyright is dedicated to the Public Domain.
|
||||
- http://creativecommons.org/publicdomain/zero/1.0/ -->
|
||||
|
||||
<html>
|
||||
<body>
|
||||
This page contains javascript that can be included in an iframe and
|
||||
upon recieving commands over postMessage will attempt to invoke privileged
|
||||
repository management APIs.
|
||||
</body>
|
||||
<script src="../jshelper.js"></script>
|
||||
<script>
|
||||
|
||||
window.addEventListener('message', doSomething);
|
||||
var installed = false;
|
||||
|
||||
function doSomething(event) {
|
||||
if(event.data == "getSelf") {
|
||||
var origin = getOrigin(appURL);
|
||||
mozAppscb(navigator.mozApps.getSelf(),
|
||||
[{ installOrigin: '== "chrome://mochitests"',
|
||||
origin: "== " + origin.quote(),
|
||||
manifestURL: "== " + appURL.quote()
|
||||
}], "success", check, next);
|
||||
}
|
||||
else if(event.data == "uninstall") {
|
||||
var pending = navigator.mozApps.getSelf();
|
||||
pending.onsuccess = function () {
|
||||
var result = pending.result.uninstall();
|
||||
result.onsuccess = function() {
|
||||
check(true, "app has been uninstalled by the domain");
|
||||
next();
|
||||
};
|
||||
result.onerror = function() {
|
||||
check(false, "app uninstall failed");
|
||||
next();
|
||||
};
|
||||
};
|
||||
pending.onerror = function() {
|
||||
check(false, "app uninstall failed through getSelf");
|
||||
next();
|
||||
};
|
||||
}
|
||||
else if(event.data == "install") {
|
||||
debug('type of check = ' + typeof check);
|
||||
install(appURL, check, next);
|
||||
installed = true;
|
||||
}
|
||||
else if(event.data == "getInstalled") {
|
||||
if(installed == true) {
|
||||
getInstalled([appURL], check, next);
|
||||
}
|
||||
mozAppscb(navigator.mozApps.getInstalled(),
|
||||
[{}], "success", check, next);
|
||||
}
|
||||
else if(event.data == "mgmt.getAll") {
|
||||
var hostname = window.location.hostname;
|
||||
debug(hostname);
|
||||
if (hostname != "http://example.com") {
|
||||
mozAppscb(navigator.mozApps.mgmt.getAll(),
|
||||
[{ name: '== "DENIED"' }], "error", check, next);
|
||||
} else {
|
||||
mozAppscb(navigator.mozApps.mgmt.getAll(),
|
||||
[{}], "success", check, next);
|
||||
}
|
||||
}
|
||||
else if(event.data == "mgmt.event_error") {
|
||||
var hostname = window.location.hostname;
|
||||
debug(hostname);
|
||||
if (hostname != "http://example.com") {
|
||||
try {
|
||||
navigator.mozApps.mgmt.addEventListener("install", function (ev) {check(ev.application.origin);});
|
||||
} catch (e) {
|
||||
check(!e.message, e.message);
|
||||
}
|
||||
|
||||
try {
|
||||
navigator.mozApps.mgmt.removeEventListener("install", function (ev) {check(!ev.application.origin);});
|
||||
} catch (e) {
|
||||
check(!e.message, e.message);
|
||||
}
|
||||
finally {
|
||||
next();
|
||||
}
|
||||
|
||||
} else {
|
||||
mozAppscb(navigator.mozApps.mgmt.getAll(),
|
||||
[{}], "success", check, next);
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</html>
|
|
@ -1,4 +0,0 @@
|
|||
{
|
||||
"name": "Super Crazy Basic App",
|
||||
"installs_allowed_from": [ "*" ]
|
||||
}
|
|
@ -1,4 +0,0 @@
|
|||
{
|
||||
"name": "Wild and Crazy Basic App",
|
||||
"installs_allowed_from": [ "*" ]
|
||||
}
|
|
@ -1 +0,0 @@
|
|||
Content-Type: application/x-web-app-manifest+json
|
|
@ -3,9 +3,11 @@
|
|||
<!-- Any copyright is dedicated to the Public Domain.
|
||||
- http://creativecommons.org/publicdomain/zero/1.0/ -->
|
||||
|
||||
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
||||
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||
title="Mozilla Bug 765063 Helper">
|
||||
<script>
|
||||
navigator.mozApps.install("http://www.example.com:80/chrome/dom/tests/mochitest/webapps/apps/super_crazy.webapp", null);
|
||||
var url = "http://test/chrome/dom/tests/mochitest/webapps/apps/basic.webapp";
|
||||
navigator.mozApps.install(url, null);
|
||||
document.location = "about:blank";
|
||||
</script>
|
||||
</window>
|
|
@ -0,0 +1,41 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Cross Origin Helper</title>
|
||||
<script type="application/javascript" src="head.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<script type="application/javascript">
|
||||
|
||||
/**
|
||||
* Install an app, check that getSelf() works, and then tell the test page
|
||||
* to continue the tests.
|
||||
*
|
||||
* This page loads on a different origin than the one for the test page,
|
||||
* which enables that page to check the behavior of various API calls when apps
|
||||
* have been installed from multiple origins.
|
||||
*/
|
||||
|
||||
var parent = SpecialPowers.wrap(window).parent;
|
||||
|
||||
confirmNextInstall();
|
||||
navigator.mozApps.install(parent.url2, null).onsuccess = function onInstall() {
|
||||
// Give the test page a reference to the installed app, so it can uninstall it
|
||||
// after it finishes the tests.
|
||||
parent.app2 = this.result;
|
||||
|
||||
navigator.mozApps.getSelf().onsuccess = function onGetSelf() {
|
||||
parent.ok(this.result instanceof Components.interfaces.mozIDOMApplication,
|
||||
"getSelf() from app's origin returns mozIDOMApplication");
|
||||
parent.is(this.result.manifestURL, parent.url2,
|
||||
"getSelf() from app's origin returns origin's app");
|
||||
|
||||
// Tell the test page to continue the tests.
|
||||
parent.postMessage("next", "*");
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,62 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
/**
|
||||
* DOMApplicationRegistry._isLaunchable() sometimes returns false right after
|
||||
* installation on Mac, perhaps because of a race condition between
|
||||
* WebappsInstaller and nsIMacWebAppUtils::pathForAppWithIdentifier().
|
||||
* That causes methods like mgmt.getAll() to exclude the app from their results,
|
||||
* even though the app is registered and installed.
|
||||
*
|
||||
* To work around this problem, set DOMApplicationRegistry.allAppsLaunchable
|
||||
* to true, which makes _isLaunchable() return true for all registered apps.
|
||||
*/
|
||||
function makeAllAppsLaunchable() {
|
||||
var Webapps = {};
|
||||
Components.utils.import("resource://gre/modules/Webapps.jsm", Webapps);
|
||||
var originalValue = Webapps.DOMApplicationRegistry.allAppsLaunchable;
|
||||
Webapps.DOMApplicationRegistry.allAppsLaunchable = true;
|
||||
|
||||
// Clean up after ourselves once tests are done so the test page is unloaded.
|
||||
window.addEventListener("unload", function restoreAllAppsLaunchable(event) {
|
||||
if (event.target == window.document) {
|
||||
window.removeEventListener("unload", restoreAllAppsLaunchable, false);
|
||||
Webapps.DOMApplicationRegistry.allAppsLaunchable = originalValue;
|
||||
}
|
||||
}, false);
|
||||
}
|
||||
|
||||
function runAll(steps) {
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
makeAllAppsLaunchable();
|
||||
|
||||
// Clone the array so we don't modify the original.
|
||||
steps = steps.concat();
|
||||
function next() {
|
||||
if (steps.length) {
|
||||
steps.shift()(next);
|
||||
}
|
||||
else {
|
||||
SimpleTest.finish();
|
||||
}
|
||||
}
|
||||
next();
|
||||
}
|
||||
|
||||
function confirmNextInstall() {
|
||||
var Ci = Components.interfaces;
|
||||
|
||||
var popupPanel = SpecialPowers.wrap(window).top.
|
||||
QueryInterface(Ci.nsIInterfaceRequestor).
|
||||
getInterface(Ci.nsIWebNavigation).
|
||||
QueryInterface(Ci.nsIDocShell).
|
||||
chromeEventHandler.ownerDocument.defaultView.
|
||||
PopupNotifications.panel;
|
||||
|
||||
function onPopupShown() {
|
||||
popupPanel.removeEventListener("popupshown", onPopupShown, false);
|
||||
SpecialPowers.wrap(this).childNodes[0].button.doCommand();
|
||||
}
|
||||
popupPanel.addEventListener("popupshown", onPopupShown, false);
|
||||
}
|
|
@ -1,306 +0,0 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
var SERVERS = {
|
||||
"_primary":"http://127.0.0.1:8088",
|
||||
"super_crazy":"http://www.example.com:80/chrome/dom/tests/mochitest/webapps/apps/super_crazy.webapp",
|
||||
"wild_crazy":"http://www.example.com:80/chrome/dom/tests/mochitest/webapps/apps/wild_crazy.webapp",
|
||||
"app_with_simple_service":"http://127.0.0.1:8888/tests/dom/tests/mochitest/webapps/servers/app_with_simple_service",
|
||||
"bad_content_type":"http://test2.example.org:80/chrome/dom/tests/mochitest/webapps/apps/bad_content_type.webapp",
|
||||
"json_syntax_error":"http://sub1.test1.example.org:80/chrome/dom/tests/mochitest/webapps/apps/json_syntax_error.webapp",
|
||||
"manifest_with_bom":"http://sub1.test2.example.org:80/chrome/dom/tests/mochitest/webapps/apps/manifest_with_bom.webapp",
|
||||
"missing_required_field":"http://sub2.test1.example.org:80/chrome/dom/tests/mochitest/webapps/apps/missing_required_field.webapp",
|
||||
"no_delegated_install":"http://sub2.test2.example.org:80/chrome/dom/tests/mochitest/webapps/apps/no_delegated_install.webapp"
|
||||
};
|
||||
|
||||
popup_listener();
|
||||
|
||||
var DEBUG = false;
|
||||
|
||||
/**
|
||||
* Wraps objects from the chrome context, and allows them to be accessed via the iframe
|
||||
* @name The id of the iframe that is being loaded
|
||||
* @check An abstraction over ok / todo to allow for that determination to be made by the invoking code
|
||||
* @next The next operation to jump to, this might need to be invoked by the iframe when the test has completed
|
||||
*/
|
||||
|
||||
function onIframeLoad(name, check, next) {
|
||||
document.getElementById(name).contentWindow.wrappedJSObject.next = next;
|
||||
document.getElementById(name).contentWindow.wrappedJSObject.getOrigin = getOrigin;
|
||||
document.getElementById(name).contentWindow.wrappedJSObject.check = check;
|
||||
document.getElementById(name).contentWindow.wrappedJSObject.debug = debug;
|
||||
document.getElementById(name).contentWindow.wrappedJSObject.appURL = SERVERS[name];
|
||||
document.getElementById(name).contentWindow.wrappedJSObject.popup_listener = popup_listener;
|
||||
document.getElementById(name).contentWindow.wrappedJSObject.readFile = readFile;
|
||||
}
|
||||
|
||||
function subsetOf(resultObj, list) {
|
||||
var returnObj = {} ;
|
||||
for (var i=0; i < list.length; i++) {
|
||||
returnObj[list[i]] = resultObj[list[i]];
|
||||
}
|
||||
return returnObj;
|
||||
}
|
||||
|
||||
/**
|
||||
* Uninstall uninstalls a specific App
|
||||
* @appURL The manifest app url
|
||||
* @check An abstraction over ok / todo to allow for that determination to be made by the invoking code
|
||||
* @next The next operation to jump to, this might need to be invoked by the iframe when the test has completed
|
||||
*/
|
||||
|
||||
function uninstall(appURL, check, next) {
|
||||
var found = false;
|
||||
var finished = false;
|
||||
var pending = navigator.mozApps.getInstalled();
|
||||
pending.onsuccess = function () {
|
||||
var m = this.result;
|
||||
for (var i=0; i < m.length; i++) {
|
||||
var app = m[i];
|
||||
if (app.manifestURL == appURL) {
|
||||
found = true;
|
||||
var pendingUninstall = app.uninstall();
|
||||
pendingUninstall.onsuccess = function(r) {
|
||||
finished = true;
|
||||
check(true, "app has been uninstalled");
|
||||
try {
|
||||
var secondUninstall = app.uninstall();
|
||||
secondUninstall.onsuccess = function(r) {
|
||||
check(false, "mozApps allowed second uninstall without error");
|
||||
next();
|
||||
};
|
||||
secondUninstall.onerror = function(r) {
|
||||
debug("Got second error: " + this.error.name);
|
||||
check(
|
||||
this.error.name == "NOT_INSTALLED",
|
||||
"The second mozApps uninstall should return an error with the name " +
|
||||
"NOT_INSTALLED, not " + this.error.name);
|
||||
next();
|
||||
};
|
||||
}
|
||||
catch(e) {
|
||||
check(false, "Unexpected error calling uninstall: " + e);
|
||||
next();
|
||||
}
|
||||
};
|
||||
pendingUninstall.onerror = function () {
|
||||
check(false, "Got error in uninstall: " + this.error.name);
|
||||
finished = true;
|
||||
};
|
||||
}
|
||||
}
|
||||
if (! found) {
|
||||
check(false, "Found no app with manifest URL: " + appURL);
|
||||
}
|
||||
};
|
||||
pending.onerror = function () {
|
||||
check(false, "Unexpected on error called in uninstall " );
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* A function that recurses a javascript object, and compares with the template to determine if the object has the expected properties
|
||||
* @check An abstraction over ok / todo to allow for that determination to be made by the invoking code
|
||||
* @object Most likely a DOM object
|
||||
*/
|
||||
|
||||
function js_traverse(template, check, object) {
|
||||
var type = typeof template;
|
||||
|
||||
// We apply SpecialPowers wrappers to the template to signal cases where
|
||||
// we need to wrap the object to examine it. We do things this way, rather
|
||||
// than wrapping unconditionally, to make sure that the default environment of
|
||||
// the test suite is as close to that of the web as possible.
|
||||
if (SpecialPowers.isWrapper(template))
|
||||
object = SpecialPowers.wrap(object);
|
||||
|
||||
if (type == "object") {
|
||||
if (Object.keys(template).length == 0) {
|
||||
check(!object || object.length == 0,"The return object from mozApps api was null as expected");
|
||||
return;
|
||||
}
|
||||
for (var key in template) {
|
||||
debug("key: " + key);
|
||||
var accessor = key.split(".",1);
|
||||
if (accessor.length > 1) {
|
||||
js_traverse(template[key], check, object[accessor[0]].accessor[1]);
|
||||
} else {
|
||||
var value = (key == "status") ? SpecialPowers.wrap(object)[key] : object[key];
|
||||
if(value) {
|
||||
js_traverse(template[key], check, value);
|
||||
} else {
|
||||
check(typeof template[key] == "undefined", key + " is undefined as expected");
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
var evaluate = "";
|
||||
|
||||
try {
|
||||
debug("object = " + object.quote());
|
||||
debug("template = " + template);
|
||||
|
||||
evaluate = object.quote() + template;
|
||||
}
|
||||
catch (e) {
|
||||
debug("template = " + template);
|
||||
evaluate = object + template;
|
||||
}
|
||||
|
||||
debug("evaluate = " + evaluate);
|
||||
debug(eval(evaluate));
|
||||
check(eval(evaluate), "#" + object + "# is expected to be true per template #" + template + "#");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to compare the result of a navigator.mozApps query, and jump to the next operation
|
||||
* @pending the variable hold the result of the navigator.mozApps query
|
||||
* @comparatorObj the array of json objects, representing what should be returned from the mozApps query
|
||||
* @check An abstraction over ok / todo to allow for that determination to be made by the invoking code
|
||||
* @next The next operation to jump to
|
||||
*/
|
||||
function mozAppscb(pending, comparatorObj, expectedStatus, check, next) {
|
||||
debug("inside mozAppscb");
|
||||
pending.onsuccess = function () {
|
||||
debug("success cb, called");
|
||||
check(expectedStatus == "success", "the success callback was called");
|
||||
if(pending.result) {
|
||||
if(typeof pending.result.length !== 'undefined') {
|
||||
for(i=0;i < pending.result.length;i++) {
|
||||
js_traverse(comparatorObj[i], check, pending.result[i]);
|
||||
}
|
||||
} else {
|
||||
debug("comparatorOBj in else");
|
||||
js_traverse(comparatorObj[0], check, pending.result);
|
||||
}
|
||||
} else {
|
||||
js_traverse(comparatorObj[0], check, null);
|
||||
}
|
||||
if(typeof next == 'function') {
|
||||
debug("calling next");
|
||||
next();
|
||||
}
|
||||
};
|
||||
|
||||
pending.onerror = function () {
|
||||
debug("failure cb called");
|
||||
check(expectedStatus == "error", "the error callback was called");
|
||||
js_traverse(comparatorObj[0], check, pending.error);
|
||||
if(typeof next == 'function') {
|
||||
debug("calling next");
|
||||
next();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function to step through the various steps of the test
|
||||
* @steps an array of steps that we need to traverse in order to complete the test
|
||||
*/
|
||||
|
||||
function runAll(steps) {
|
||||
var index = 0;
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
function callNext() {
|
||||
if (index >= steps.length - 1) {
|
||||
steps[index]();
|
||||
SimpleTest.finish();
|
||||
return;
|
||||
}
|
||||
debug("index = " + index);
|
||||
var func = steps[index];
|
||||
index++;
|
||||
func(callNext);
|
||||
}
|
||||
callNext();
|
||||
}
|
||||
|
||||
/**
|
||||
* Install installs a specific App
|
||||
* @appURL The manifest app url
|
||||
* @check An abstraction over ok / todo to allow for that determination to be made by the invoking code
|
||||
* @next The next operation to jump to, this might need to be invoked by the iframe when the test has completed
|
||||
*/
|
||||
|
||||
function install(appURL, check, next) {
|
||||
var origin = getOrigin(appURL);
|
||||
debug("origin = " + origin);
|
||||
var installOrigin = getOrigin(window.location.href);
|
||||
debug("installOrigin = " + installOrigin);
|
||||
var url = appURL.substring(appURL.indexOf('/apps/'));
|
||||
var manifest = JSON.parse(readFile(url));
|
||||
if(!manifest.installs_allowed_from) {
|
||||
manifest.installs_allowed_from = undefined;
|
||||
} else {
|
||||
for (var i = 0 ; i < manifest.installs_allowed_from.length; i++)
|
||||
manifest.installs_allowed_from[i] = "== " + manifest.installs_allowed_from[i].quote();
|
||||
}
|
||||
mozAppscb(navigator.mozApps.install(
|
||||
appURL, null),
|
||||
[{
|
||||
installOrigin: "== " + installOrigin.quote(),
|
||||
installTime: "!== undefined",
|
||||
origin: "== " + origin.quote(),
|
||||
manifestURL: "== " + appURL.quote(),
|
||||
// |manifest| is not accessible to content, so js_traverse needs to
|
||||
// use SpecialPowers to see it. We signal this by wrapping it.
|
||||
manifest: SpecialPowers.wrap({
|
||||
name: "== " + unescape(manifest.name).quote(),
|
||||
installs_allowed_from: manifest.installs_allowed_from
|
||||
})
|
||||
}], "success", check,
|
||||
next);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets an installed App and compares it against the expected
|
||||
* @appURL The manifest app url
|
||||
* @check An abstraction over ok / todo to allow for that determination to be made by the invoking code
|
||||
* @next The next operation to jump to, this might need to be invoked by the iframe when the test has completed
|
||||
*/
|
||||
|
||||
function getInstalled(appURLs, check, next) {
|
||||
var checkInstalled = [];
|
||||
for (var i = 0; i < appURLs.length ; i++) {
|
||||
var appURL = appURLs[i];
|
||||
var origin = getOrigin(appURL);
|
||||
var url = appURL.substring(appURL.indexOf('/apps/'));
|
||||
var manifest = JSON.parse(readFile(url));
|
||||
|
||||
if(manifest.installs_allowed_from) {
|
||||
for (var j = 0 ; j < manifest.installs_allowed_from.length; j++)
|
||||
manifest.installs_allowed_from[j] = "== " + manifest.installs_allowed_from[j].quote();
|
||||
}
|
||||
|
||||
checkInstalled[i] = {
|
||||
installOrigin: "== " + "chrome://mochitests".quote(),
|
||||
origin: "== " + origin.quote(),
|
||||
manifestURL: "== " + appURL.quote(),
|
||||
installTime: " \> Date.now() - 3000",
|
||||
// |manifest| is not accessible to content, so js_traverse needs to
|
||||
// use SpecialPowers to see it. We signal this by wrapping it.
|
||||
manifest: SpecialPowers.wrap({
|
||||
name: "== " + unescape(manifest.name).quote(),
|
||||
installs_allowed_from: manifest.installs_allowed_from
|
||||
})
|
||||
};
|
||||
}
|
||||
debug(JSON.stringify(checkInstalled));
|
||||
mozAppscb(navigator.mozApps.getInstalled(), checkInstalled, "success", check, next);
|
||||
}
|
||||
|
||||
/**
|
||||
* debug function, which basically controls what goes to stdout
|
||||
* @msg The message you want to output
|
||||
*/
|
||||
function debug(msg) {
|
||||
if(DEBUG == true) {
|
||||
dump(msg + "\n");
|
||||
}
|
||||
}
|
||||
function check_event_listener_fired (next) {
|
||||
todo(triggered, "Event Listener fired");
|
||||
triggered = false;
|
||||
next();
|
||||
}
|
|
@ -9,33 +9,50 @@
|
|||
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||
title="Mozilla Bug 765063">
|
||||
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
|
||||
<script type="application/javascript" src="apphelper.js"/>
|
||||
<!-- We only need jshelper.js for debug(), which apphelper.js calls. But
|
||||
- since we include it, we also let it call apphelper.js's popup_listener(),
|
||||
- which listens for the install doorhanger and presses its main button. -->
|
||||
<script type="application/javascript" src="jshelper.js"/>
|
||||
<script type="application/javascript" src="head.js"/>
|
||||
<!-- test results are displayed in the html:body -->
|
||||
<body xmlns="http://www.w3.org/1999/xhtml">
|
||||
<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=741549"
|
||||
target="_blank">Mozilla Bug 765063</a>
|
||||
</body>
|
||||
|
||||
<script>
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
makeAllAppsLaunchable();
|
||||
|
||||
var url = "http://test/chrome/dom/tests/mochitest/webapps/apps/basic.webapp";
|
||||
|
||||
// Observe app installation and confirm that the install origin didn't change.
|
||||
var observer = {
|
||||
observe: function observe(subject, topic, data) {
|
||||
Services.obs.removeObserver(observer, "webapps-sync-install");
|
||||
ok(JSON.parse(data).installOrigin == "http://www.example.com",
|
||||
is(JSON.parse(data).installOrigin, "http://test",
|
||||
"the install origin didn't change");
|
||||
tearDown();
|
||||
SimpleTest.finish();
|
||||
|
||||
navigator.mozApps.mgmt.getAll().onsuccess = function onGetAll() {
|
||||
var app = [a for each (a in this.result) if (a.manifestURL == url)][0];
|
||||
app.uninstall().onsuccess = function onUninstall() {
|
||||
SimpleTest.finish();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Components.utils.import("resource://gre/modules/Services.jsm");
|
||||
Services.obs.addObserver(observer, "webapps-sync-install", false);
|
||||
|
||||
// We call this here, even though the app is installed by the helper page,
|
||||
// because the helper page redirect would cause its install listener to unload
|
||||
// before it can confirm the install.
|
||||
confirmNextInstall();
|
||||
|
||||
</script>
|
||||
|
||||
<!-- Load a page that initiates an app installation and then immediately
|
||||
- redirects to a page at a different origin. We can't do this directly
|
||||
- inside this test page, because that would cause the test to hang. -->
|
||||
<iframe src="http://www.example.com:80/chrome/dom/tests/mochitest/webapps/apps/bug_765063.xul"/>
|
||||
<iframe src="http://test/chrome/dom/tests/mochitest/webapps/bug_765063.xul"/>
|
||||
|
||||
</window>
|
||||
|
|
|
@ -1,108 +0,0 @@
|
|||
<?xml version="1.0"?>
|
||||
<?xml-stylesheet type="text/css" href="chrome://global/skin"?>
|
||||
<?xml-stylesheet type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"?>
|
||||
|
||||
<!-- Any copyright is dedicated to the Public Domain.
|
||||
- http://creativecommons.org/publicdomain/zero/1.0/
|
||||
- https://bugzilla.mozilla.org/show_bug.cgi?id=741549
|
||||
-->
|
||||
<window title="Mozilla Bug 741549"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
||||
<script type="application/javascript" src="chrome://mochikit/content/chrome-harness.js"></script>
|
||||
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
|
||||
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/>
|
||||
<script type="application/javascript" src="apphelper.js"/>
|
||||
<script type="application/javascript" src="jshelper.js"/>
|
||||
|
||||
<!-- test results are displayed in the html:body -->
|
||||
<head></head>
|
||||
<body xmlns="http://www.w3.org/1999/xhtml">
|
||||
<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=741549"
|
||||
target="_blank">Mozilla Bug 741549</a>
|
||||
<iframe id="super_crazy" onload="go();" src="http://www.example.com:80/chrome/dom/tests/mochitest/webapps/apps/include.html"/>
|
||||
<iframe id="no_delegated_install" onload="go();" src="http://sub2.test2.example.org:80/chrome/dom/tests/mochitest/webapps/apps/include.html"/>
|
||||
|
||||
</body>
|
||||
|
||||
<script>
|
||||
|
||||
steps = [get_installed_returns_nothing, install_super_crazy, check_event_listener_fired, get_self_returns_nothing,
|
||||
get_self_on_domain, install_on_domain, check_event_listener_fired, get_all_installed,
|
||||
get_installed_on_domain, uninstall_on_domain, get_all_on_domain, tearDown];
|
||||
var iframes_loaded = 0 ;
|
||||
|
||||
function go() {
|
||||
++iframes_loaded;
|
||||
if (iframes_loaded >= 2) {
|
||||
runAll(steps);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function get_installed_returns_nothing(next) {
|
||||
debug("in " + arguments.callee.name);
|
||||
mozAppscb(navigator.mozApps.getInstalled(),
|
||||
[{}],
|
||||
"success",
|
||||
ok,
|
||||
next);
|
||||
}
|
||||
|
||||
function install_super_crazy(next) {
|
||||
debug("in " + arguments.callee.name);
|
||||
var appURL = SERVERS['super_crazy'];
|
||||
|
||||
install(appURL, ok, function() {
|
||||
getInstalled([appURL], ok, next);
|
||||
});
|
||||
}
|
||||
|
||||
function get_self_returns_nothing(next) {
|
||||
debug("in " + arguments.callee.name);
|
||||
mozAppscb(navigator.mozApps.getSelf(),
|
||||
[{}],
|
||||
"success",
|
||||
ok,
|
||||
next);
|
||||
}
|
||||
|
||||
function get_self_on_domain(next) {
|
||||
debug("in " + arguments.callee.name);
|
||||
onIframeLoad("super_crazy", ok, next);
|
||||
document.getElementById("super_crazy").contentWindow.postMessage("getSelf", '*');
|
||||
}
|
||||
|
||||
function install_on_domain(next) {
|
||||
debug("in " + arguments.callee.name);
|
||||
onIframeLoad("no_delegated_install", ok, next);
|
||||
document.getElementById("no_delegated_install").contentWindow.postMessage("install", '*');
|
||||
}
|
||||
|
||||
function get_all_installed(next) {
|
||||
debug("in " + arguments.callee.name);
|
||||
var appURLs = [SERVERS['super_crazy'], SERVERS['no_delegated_install']];
|
||||
getInstalled(appURLs, ok, next);
|
||||
}
|
||||
|
||||
function uninstall_on_domain(next) {
|
||||
debug("in " + arguments.callee.name);
|
||||
onIframeLoad("super_crazy", ok, next);
|
||||
document.getElementById("super_crazy").contentWindow.postMessage("uninstall", '*');
|
||||
}
|
||||
|
||||
function get_all_on_domain(next) {
|
||||
debug("in " + arguments.callee.name);
|
||||
onIframeLoad("super_crazy", ok, next);
|
||||
document.getElementById("super_crazy").contentWindow.postMessage("mgmt.getAll", '*');
|
||||
}
|
||||
|
||||
function get_installed_on_domain(next) {
|
||||
debug("in " + arguments.callee.name);
|
||||
onIframeLoad("super_crazy", ok, next);
|
||||
document.getElementById("super_crazy").contentWindow.postMessage("getInstalled", '*');
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
</window>
|
||||
|
|
@ -0,0 +1,104 @@
|
|||
<?xml version="1.0"?>
|
||||
|
||||
<!-- Any copyright is dedicated to the Public Domain.
|
||||
- http://creativecommons.org/publicdomain/zero/1.0/ -->
|
||||
|
||||
<?xml-stylesheet type="text/css" href="chrome://global/skin"?>
|
||||
<?xml-stylesheet type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"?>
|
||||
|
||||
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||
title="Mozilla Bug 741549">
|
||||
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
|
||||
<script type="application/javascript" src="head.js"/>
|
||||
<!-- test results are displayed in the html:body -->
|
||||
<body xmlns="http://www.w3.org/1999/xhtml">
|
||||
<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=741549"
|
||||
target="_blank">Mozilla Bug 741549</a>
|
||||
</body>
|
||||
|
||||
<iframe id="iframe"/>
|
||||
|
||||
<script>
|
||||
|
||||
var url1 = "http://test1.example.com/chrome/dom/tests/mochitest/webapps/apps/basic.webapp";
|
||||
var url2 = "http://test2.example.com/chrome/dom/tests/mochitest/webapps/apps/basic.webapp";
|
||||
|
||||
// References to the apps we install, so we can uninstall them afterward.
|
||||
// Note that app2 is set by the helper page, which throws "TypeError: can't
|
||||
// redefine non-configurable property 'app2'" if we declare it here.
|
||||
var app1 /* , app2 */;
|
||||
|
||||
var steps = [
|
||||
installAppFromOwnOrigin,
|
||||
installAppFromOtherOrigin,
|
||||
getInstalled,
|
||||
getAll,
|
||||
uninstall,
|
||||
];
|
||||
|
||||
runAll(steps);
|
||||
|
||||
/**
|
||||
* Install the first app from our own origin (chrome://mochitests). Note that
|
||||
* the app itself is from a different origin (http://test1.example.com).
|
||||
*/
|
||||
function installAppFromOwnOrigin(next) {
|
||||
confirmNextInstall();
|
||||
navigator.mozApps.install(url1, null).onsuccess = function onInstall() {
|
||||
app1 = this.result;
|
||||
next();
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Install the second app from another origin (http://test2.example.com) using
|
||||
* the helper page. In this case, the origin of the installing page is the same
|
||||
* as the origin of the app being installed, so the helper page can test
|
||||
* getSelf().
|
||||
*/
|
||||
function installAppFromOtherOrigin(next) {
|
||||
document.getElementById("iframe").setAttribute("src",
|
||||
"http://test2.example.com/chrome/dom/tests/mochitest/webapps/cross_origin.html");
|
||||
|
||||
window.addEventListener("message", function onMessage(event) {
|
||||
if (event.data == "next") {
|
||||
window.removeEventListener("message", onMessage, false);
|
||||
next();
|
||||
}
|
||||
}, false);
|
||||
}
|
||||
|
||||
function getInstalled(next) {
|
||||
navigator.mozApps.getInstalled().onsuccess = function onGetInstalled() {
|
||||
var app1 = [a for each (a in this.result) if (a.manifestURL == url1)][0];
|
||||
ok(app1, "getInstalled() includes app installed from own origin");
|
||||
|
||||
var app2 = [a for each (a in this.result) if (a.manifestURL == url2)][0];
|
||||
ok(!app2, "getInstalled() excludes app installed from other origin");
|
||||
|
||||
next();
|
||||
};
|
||||
}
|
||||
|
||||
function getAll(next) {
|
||||
navigator.mozApps.mgmt.getAll().onsuccess = function onMgmtGetAll() {
|
||||
var app1 = [a for each (a in this.result) if (a.manifestURL == url1)][0];
|
||||
ok(app1, "mgmt.getAll() includes app installed from own origin");
|
||||
|
||||
var app2 = [a for each (a in this.result) if (a.manifestURL == url2)][0];
|
||||
ok(app2, "mgmt.getAll() includes app installed from other origin");
|
||||
|
||||
next();
|
||||
};
|
||||
}
|
||||
|
||||
function uninstall(next) {
|
||||
app1.uninstall().onsuccess = function onUninstallApp1() {
|
||||
app2.uninstall().onsuccess = function onUninstallApp2() {
|
||||
next();
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
</script>
|
||||
</window>
|
|
@ -8,61 +8,97 @@
|
|||
|
||||
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||
title="Mozilla Bug 781379">
|
||||
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
|
||||
<script type="application/javascript" src="apphelper.js"/>
|
||||
<script type="application/javascript" src="jshelper.js"/>
|
||||
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
|
||||
<script type="application/javascript" src="head.js"/>
|
||||
<!-- test results are displayed in the html:body -->
|
||||
<body xmlns="http://www.w3.org/1999/xhtml">
|
||||
<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=741549"
|
||||
target="_blank">Mozilla Bug 781379</a>
|
||||
</body>
|
||||
|
||||
<script type="application/javascript;version=1.8">
|
||||
|
||||
const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components;
|
||||
Cu.import("resource://gre/modules/Webapps.jsm");
|
||||
|
||||
let notInstalled = 0;
|
||||
// We use a different origin than other webapps test files because we compare
|
||||
// the number of apps before and after installing this one; and if a test file
|
||||
// installs our app and then doesn't uninstall it (f.e. because it isn't written
|
||||
// to clean up after itself, or because it throws an exception or times out),
|
||||
// then this test will *reinstall* the app, and the number of apps won't change,
|
||||
// which will look like a failure in this test although it's actually a failure
|
||||
// in the other one.
|
||||
//
|
||||
// Using a different origin here isn't a foolproof solution, as another test
|
||||
// could start using it. Reviewer vigilance is required! And to anyone reading
|
||||
// this: don't use this origin without good reason and due consideration for
|
||||
// the potential consequences!
|
||||
//
|
||||
// Alternately, we could define a test-specific domain, getNotInstalled.com,
|
||||
// in source/build/pgo/server-locations.txt. But that seems like overkill,
|
||||
// and this problem will go away once we support multiple apps per origin,
|
||||
// since then we can make this test install its own personal webapp from any
|
||||
// origin.
|
||||
//
|
||||
let url = "http://example.com/chrome/dom/tests/mochitest/webapps/apps/basic.webapp";
|
||||
|
||||
let app, notInstalled, _isLaunchable;
|
||||
|
||||
let _isLaunchable;
|
||||
let steps = [
|
||||
monkeyPatchDOMApplicationRegistry, getNotInstalled, installApp,
|
||||
compareNotInstalled, unmonkeyPatchDOMApplicationRegistry, cleanUp, tearDown
|
||||
monkeyPatchDOMApplicationRegistry,
|
||||
getNotInstalled,
|
||||
installApp,
|
||||
compareNotInstalled,
|
||||
unmonkeyPatchDOMApplicationRegistry,
|
||||
uninstallApp,
|
||||
];
|
||||
|
||||
runAll(steps);
|
||||
|
||||
// Monkey patch DOMApplicationRegistry._isLaunchable for testing.
|
||||
// This way, we don't have to create a platform specific application with a
|
||||
// status other than "installed".
|
||||
function monkeyPatchDOMApplicationRegistry (next) {
|
||||
function monkeyPatchDOMApplicationRegistry(next) {
|
||||
_isLaunchable = DOMApplicationRegistry._isLaunchable;
|
||||
DOMApplicationRegistry._isLaunchable = function mockIsLaunchable (aOrigin) {
|
||||
DOMApplicationRegistry._isLaunchable = function mockIsLaunchable(aOrigin) {
|
||||
return false;
|
||||
}
|
||||
next();
|
||||
}
|
||||
|
||||
// Call navigator.mozApps.mgmt.getNotInstalled and save the result.
|
||||
function getNotInstalled (next) {
|
||||
window.navigator.mozApps.mgmt.getNotInstalled().onsuccess = function() {
|
||||
function getNotInstalled(next) {
|
||||
window.navigator.mozApps.mgmt.getNotInstalled().onsuccess =
|
||||
function onGetNotInstalled() {
|
||||
notInstalled = this.result.length;
|
||||
next();
|
||||
};
|
||||
}
|
||||
|
||||
// Add an app to the appregistry
|
||||
function installApp (next) {
|
||||
let appURL = SERVERS["super_crazy"];
|
||||
install(appURL, ok, next);
|
||||
function installApp(next) {
|
||||
confirmNextInstall();
|
||||
navigator.mozApps.install(url, null).onsuccess = function onInstall() {
|
||||
app = this.result;
|
||||
next();
|
||||
}
|
||||
}
|
||||
|
||||
// Call navigator.mozApps.mgmt.getNotInstalled and make sure there is one more.
|
||||
function compareNotInstalled (next) {
|
||||
function compareNotInstalled(next) {
|
||||
let results;
|
||||
function getNotInstalledError () {
|
||||
function getNotInstalledError() {
|
||||
ok(false, "window.mozApps.mgmt.getNotInstalled onerror called");
|
||||
next();
|
||||
}
|
||||
function getNotInstalledSuccess () {
|
||||
function getNotInstalledSuccess() {
|
||||
ok(true, "window.mozApps.mgmt.getNotInstalled onsuccess called");
|
||||
is(this.result.length, notInstalled + 1, "should get one more notInstalled app");
|
||||
is(this.result.length, notInstalled + 1,
|
||||
"should get one more notInstalled app");
|
||||
|
||||
if (this.result.length > 0) {
|
||||
is(this.result[this.result.length-1].origin, "http://www.example.com",
|
||||
"getNotInstalled returned the expected app");
|
||||
is(this.result[this.result.length-1].origin, "http://example.com",
|
||||
"getNotInstalled returned the expected app");
|
||||
}
|
||||
next();
|
||||
}
|
||||
|
@ -81,20 +117,22 @@ function compareNotInstalled (next) {
|
|||
}
|
||||
}
|
||||
|
||||
function unmonkeyPatchDOMApplicationRegistry (next) {
|
||||
function unmonkeyPatchDOMApplicationRegistry(next) {
|
||||
if (typeof _isLaunchable === "function") {
|
||||
DOMApplicationRegistry._isLaunchable = _isLaunchable;
|
||||
ok(true, "restored DOMApplicationRegistry._isLaunchable")
|
||||
ok(true, "restored DOMApplicationRegistry._isLaunchable");
|
||||
} else {
|
||||
ok(false, "can't restore DOMApplicationRegistry._isLaunchable")
|
||||
ok(false, "can't restore DOMApplicationRegistry._isLaunchable");
|
||||
}
|
||||
next();
|
||||
}
|
||||
|
||||
// Remove installed app.
|
||||
function cleanUp (next) {
|
||||
let appURL = SERVERS["super_crazy"];
|
||||
uninstall(appURL, ok, next);
|
||||
// Remove the app from the appregistry
|
||||
function uninstallApp(next) {
|
||||
app.uninstall().onsuccess = function onUninstall() {
|
||||
app = null;
|
||||
next();
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
|
|
|
@ -1,73 +1,100 @@
|
|||
<?xml version="1.0"?>
|
||||
|
||||
<!-- Any copyright is dedicated to the Public Domain.
|
||||
- http://creativecommons.org/publicdomain/zero/1.0/ -->
|
||||
|
||||
<?xml-stylesheet type="text/css" href="chrome://global/skin"?>
|
||||
<?xml-stylesheet type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"?>
|
||||
|
||||
<!-- Any copyright is dedicated to the Public Domain.
|
||||
- http://creativecommons.org/publicdomain/zero/1.0/
|
||||
- https://bugzilla.mozilla.org/show_bug.cgi?id=741549
|
||||
-->
|
||||
|
||||
<window title="Mozilla Bug 741549"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
||||
<script type="application/javascript" src="chrome://mochikit/content/chrome-harness.js"></script>
|
||||
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||
title="Mozilla Bug 741549">
|
||||
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
|
||||
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/>
|
||||
<script type="application/javascript" src="apphelper.js"/>
|
||||
<script type="application/javascript" src="jshelper.js"/>
|
||||
<script type="application/javascript" src="head.js"/>
|
||||
<!-- test results are displayed in the html:body -->
|
||||
<body xmlns="http://www.w3.org/1999/xhtml">
|
||||
<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=741549"
|
||||
target="_blank">Mozilla Bug 741549</a> <br />
|
||||
target="_blank">Mozilla Bug 741549</a><br/>
|
||||
<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=734294"
|
||||
target="_blank">Mozilla Bug 734294</a>
|
||||
</body>
|
||||
|
||||
<script>
|
||||
<script>
|
||||
<![CDATA[
|
||||
|
||||
steps = [get_installed_returns_nothing, get_self_returns_nothing,
|
||||
install_wild_crazy, uninstall_wild_crazy, tearDown];
|
||||
var url = "http://test/chrome/dom/tests/mochitest/webapps/apps/basic.webapp";
|
||||
var app;
|
||||
|
||||
var steps = [
|
||||
getInstalledReturnsNothing,
|
||||
install,
|
||||
getInstalledReturnsApp,
|
||||
getSelf,
|
||||
uninstall,
|
||||
];
|
||||
|
||||
runAll(steps);
|
||||
|
||||
function get_installed_returns_nothing(next) {
|
||||
debug("in " + arguments.callee.name);
|
||||
mozAppscb(navigator.mozApps.getInstalled(),
|
||||
[{}],
|
||||
"success",
|
||||
ok,
|
||||
next);
|
||||
function getInstalledReturnsNothing(next) {
|
||||
navigator.mozApps.getInstalled().onsuccess = function() {
|
||||
is(this.result.length, 0, "getInstalled() returns nothing");
|
||||
next();
|
||||
};
|
||||
}
|
||||
|
||||
function get_self_returns_nothing(next) {
|
||||
debug("in " + arguments.callee.name);
|
||||
mozAppscb(navigator.mozApps.getSelf(),
|
||||
[{}],
|
||||
"success",
|
||||
ok,
|
||||
next);
|
||||
function install(next) {
|
||||
var beforehand = Date.now();
|
||||
|
||||
confirmNextInstall();
|
||||
navigator.mozApps.install(url, null).onsuccess = function onInstall() {
|
||||
app = this.result;
|
||||
|
||||
is(app.origin, "http://test", "origin");
|
||||
is(app.installOrigin, "chrome://mochitests", "install origin");
|
||||
ok(app.installTime >= beforehand, "install time is after install() call");
|
||||
ok(app.installTime <= Date.now(), "install time is before install success");
|
||||
is(app.manifestURL, url, "manifest URL");
|
||||
is(app.manifest.name, "Basic App", "manifest.name");
|
||||
is(app.manifest.installs_allowed_from, "*",
|
||||
"manifest.installs_allowed_from");
|
||||
|
||||
next();
|
||||
}
|
||||
}
|
||||
|
||||
function install_wild_crazy(next) {
|
||||
debug("in " + arguments.callee.name);
|
||||
var appURL = SERVERS['wild_crazy'];
|
||||
install(appURL, ok, function() {
|
||||
getInstalled([appURL], ok, next);
|
||||
}
|
||||
);
|
||||
function getInstalledReturnsApp(next) {
|
||||
navigator.mozApps.getInstalled().onsuccess = function onGetInstalled() {
|
||||
// Retrieve the app we just installed from the list of installed apps.
|
||||
var a = [a for each (a in this.result) if (a.manifestURL == url)][0];
|
||||
|
||||
// Compare the values of the two app objects to make sure install()
|
||||
// and getInstalled() return identical objects.
|
||||
isDeeply(a, app, "getInstalled() returns app identical to install()");
|
||||
|
||||
next();
|
||||
};
|
||||
}
|
||||
|
||||
function uninstall_wild_crazy(next) {
|
||||
debug("in " + arguments.callee.name);
|
||||
var appURL = SERVERS['wild_crazy'];
|
||||
uninstall(appURL, ok, function() {
|
||||
mozAppscb(navigator.mozApps.getInstalled(),
|
||||
[{}],
|
||||
"success",
|
||||
ok,
|
||||
next);
|
||||
});
|
||||
function getSelf(next) {
|
||||
navigator.mozApps.getSelf().onsuccess = function onGetSelf() {
|
||||
is(this.result, null, "getSelf() returns nothing (different origin)");
|
||||
|
||||
next();
|
||||
};
|
||||
}
|
||||
|
||||
</script>
|
||||
function uninstall(next) {
|
||||
app.uninstall().onsuccess = function onUninstall() {
|
||||
// Try to retrieve the app we just uninstalled, to make sure it no longer
|
||||
// exists in the registry.
|
||||
navigator.mozApps.getInstalled().onsuccess = function onGetInstalled() {
|
||||
var a = [a for each (a in this.result) if (a.manifestURL == url)][0];
|
||||
is(a, undefined, "getInstalled() returns nothing again after uninstall");
|
||||
|
||||
next();
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
]]>
|
||||
</script>
|
||||
</window>
|
||||
|
|
|
@ -1,90 +1,100 @@
|
|||
<?xml version="1.0"?>
|
||||
|
||||
<!-- Any copyright is dedicated to the Public Domain.
|
||||
- http://creativecommons.org/publicdomain/zero/1.0/ -->
|
||||
|
||||
<?xml-stylesheet type="text/css" href="chrome://global/skin"?>
|
||||
<?xml-stylesheet type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"?>
|
||||
|
||||
<!-- Any copyright is dedicated to the Public Domain.
|
||||
- http://creativecommons.org/publicdomain/zero/1.0/
|
||||
- https://bugzilla.mozilla.org/show_bug.cgi?id=741549
|
||||
-->
|
||||
|
||||
<window title="Mozilla Bug 741549"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
||||
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||
title="Mozilla Bug 741549">
|
||||
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
|
||||
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/>
|
||||
<script type="application/javascript" src="apphelper.js"/>
|
||||
<script type="application/javascript" src="jshelper.js"/>
|
||||
<script type="application/javascript" src="head.js"/>
|
||||
<!-- test results are displayed in the html:body -->
|
||||
<body xmlns="http://www.w3.org/1999/xhtml">
|
||||
<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=741549"
|
||||
target="_blank">Mozilla Bug 741549</a>
|
||||
<iframe id="no_delegated_install" onload="go();" src="http://sub2.test2.example.org:80/chrome/dom/tests/mochitest/webapps/apps/include.html"/>
|
||||
</body>
|
||||
|
||||
<script>
|
||||
|
||||
function go() {
|
||||
runAll(steps);
|
||||
}
|
||||
var steps = [
|
||||
noArgs,
|
||||
parseError,
|
||||
invalidManifest,
|
||||
permissionDenied,
|
||||
invalidContent,
|
||||
];
|
||||
|
||||
steps = [no_args, parse_error, invalid_manifest, permission_denied, invalid_content,
|
||||
mgmt_api_errors, mgmt_api_add_listener, uninstall_apps, tearDown];
|
||||
runAll(steps);
|
||||
|
||||
function no_args(next) {
|
||||
debug("in " + arguments.callee.name);
|
||||
function noArgs(next) {
|
||||
try {
|
||||
navigator.mozApps.install();
|
||||
} catch (e) {
|
||||
ok(e.message == "Not enough arguments \[mozIDOMApplicationRegistry.install\]", "install returned " + e.message);
|
||||
is(e.message, "Not enough arguments \[mozIDOMApplicationRegistry.install\]",
|
||||
"install without arguments throws exception");
|
||||
next();
|
||||
}
|
||||
}
|
||||
|
||||
function parse_error(next) {
|
||||
debug("in " + arguments.callee.name);
|
||||
mozAppscb(navigator.mozApps.install(SERVERS['json_syntax_error'], null),
|
||||
[{ name: "== \"MANIFEST_PARSE_ERROR\"" }], "error", ok, next);
|
||||
function parseError(next) {
|
||||
var url = "http://test/chrome/dom/tests/mochitest/webapps/apps/json_syntax_error.webapp";
|
||||
|
||||
confirmNextInstall();
|
||||
navigator.mozApps.install(url, null).onerror = function onInstallError() {
|
||||
is(this.error.name, "MANIFEST_PARSE_ERROR", "manifest with syntax error");
|
||||
next();
|
||||
};
|
||||
}
|
||||
|
||||
function invalid_manifest(next) {
|
||||
debug("in " + arguments.callee.name);
|
||||
mozAppscb(navigator.mozApps.install(SERVERS['missing_required_field'], null),
|
||||
[{ name: "== \"INVALID_MANIFEST\"" }], "error", ok, next);
|
||||
function invalidManifest(next) {
|
||||
var url = "http://test/chrome/dom/tests/mochitest/webapps/apps/missing_required_field.webapp";
|
||||
|
||||
confirmNextInstall();
|
||||
navigator.mozApps.install(url, null).onerror = function onInstallError() {
|
||||
is(this.error.name, "INVALID_MANIFEST", "manifest missing required field");
|
||||
next();
|
||||
};
|
||||
}
|
||||
|
||||
function permission_denied(next) {
|
||||
debug("in " + arguments.callee.name);
|
||||
mozAppscb(navigator.mozApps.install(SERVERS['no_delegated_install'], null),
|
||||
[{ name: "== \"DENIED\"" }], "error", todo, next);
|
||||
function permissionDenied(next) {
|
||||
var url = "http://test/chrome/dom/tests/mochitest/webapps/apps/no_delegated_install.webapp";
|
||||
|
||||
confirmNextInstall();
|
||||
var request = navigator.mozApps.install(url, null);
|
||||
|
||||
request.onerror = function onInstallError() {
|
||||
is(this.error.name, "DENIED", "manifest without installs_allowed_from");
|
||||
next();
|
||||
};
|
||||
|
||||
request.onsuccess = function onInstall() {
|
||||
todo(false, "manifest without installs_allowed_from fails");
|
||||
this.result.uninstall().onsuccess = function onUninstall() {
|
||||
next();
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
function invalid_content(next) {
|
||||
debug("in " + arguments.callee.name);
|
||||
mozAppscb(navigator.mozApps.install(SERVERS['bad_content_type'], null),
|
||||
[{ name: "== \"INVALID_MANIFEST\"" }], "error", todo, next);
|
||||
function invalidContent(next) {
|
||||
var url = "http://test/chrome/dom/tests/mochitest/webapps/apps/bad_content_type.webapp";
|
||||
|
||||
confirmNextInstall();
|
||||
var request = navigator.mozApps.install(url, null);
|
||||
|
||||
request.onerror = function onInstallError() {
|
||||
is(this.error.name, "INVALID_MANIFEST", "manifest with bad content type");
|
||||
next();
|
||||
};
|
||||
|
||||
request.onsuccess = function onInstall() {
|
||||
todo(false, "manifest with bad content type fails");
|
||||
this.result.uninstall().onsuccess = function onUninstall() {
|
||||
next();
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
function mgmt_api_errors(next) {
|
||||
debug("in " + arguments.callee.name);
|
||||
onIframeLoad("no_delegated_install", ok, next);
|
||||
document.getElementById("no_delegated_install").contentWindow.postMessage("mgmt.getAll", '*');
|
||||
}
|
||||
|
||||
function mgmt_api_add_listener(next) {
|
||||
debug("in " + arguments.callee.name);
|
||||
onIframeLoad("no_delegated_install", todo, next);
|
||||
document.getElementById("no_delegated_install").contentWindow.postMessage("mgmt.event_error", '*');
|
||||
}
|
||||
|
||||
function uninstall_apps(next) {
|
||||
debug("in " + arguments.callee.name);
|
||||
var appURL = SERVERS['bad_content_type'];
|
||||
uninstall(appURL, ok, function() {
|
||||
appURL = SERVERS['no_delegated_install'];
|
||||
uninstall(appURL, ok, function() { next(); });
|
||||
});
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
</script>
|
||||
</window>
|
||||
|
||||
|
|
|
@ -1,59 +1,58 @@
|
|||
<?xml version="1.0"?>
|
||||
|
||||
<!-- Any copyright is dedicated to the Public Domain.
|
||||
- http://creativecommons.org/publicdomain/zero/1.0/ -->
|
||||
|
||||
<?xml-stylesheet type="text/css" href="chrome://global/skin"?>
|
||||
<?xml-stylesheet type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"?>
|
||||
|
||||
<!-- Any copyright is dedicated to the Public Domain.
|
||||
- http://creativecommons.org/publicdomain/zero/1.0/
|
||||
- https://bugzilla.mozilla.org/show_bug.cgi?id=741549
|
||||
-->
|
||||
|
||||
<window title="Mozilla Bug 741549"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
||||
<script type="application/javascript" src="chrome://mochikit/content/chrome-harness.js"></script>
|
||||
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||
title="Mozilla Bug 741549">
|
||||
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
|
||||
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/>
|
||||
<script type="application/javascript" src="apphelper.js"/>
|
||||
<script type="application/javascript" src="jshelper.js"/>
|
||||
<script type="application/javascript" src="head.js"/>
|
||||
<!-- test results are displayed in the html:body -->
|
||||
<body xmlns="http://www.w3.org/1999/xhtml">
|
||||
<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=741549"
|
||||
target="_blank">Mozilla Bug 741549</a>
|
||||
</body>
|
||||
|
||||
<script>
|
||||
<script>
|
||||
|
||||
steps = [install_super_crazy, uninstall_super_crazy, tearDown];
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
runAll(steps);
|
||||
var url = "http://test/chrome/dom/tests/mochitest/webapps/apps/basic.webapp";
|
||||
|
||||
function install_super_crazy(next) {
|
||||
debug("in " + arguments.callee.name);
|
||||
var appURL = SERVERS['super_crazy'];
|
||||
var pending = navigator.mozApps.install(appURL, {receipts: ["a",0, true,false,null,undefined,{one:1},{nest:{ed:"hi"}},NaN,Infinity]});
|
||||
pending.onsuccess = function () {
|
||||
var receipts = pending.result.receipts;
|
||||
ok(receipts[0] == "a", receipts[0]);
|
||||
ok(receipts[1] == 0, receipts[1]);
|
||||
ok(receipts[2] == true, receipts[2]);
|
||||
ok(receipts[3] == false, receipts[3]);
|
||||
ok(receipts[4] == null, receipts[4]);
|
||||
ok(receipts[5] == undefined, receipts[5]);
|
||||
ok(receipts[6].one == 1, receipts[6].one);
|
||||
ok(receipts[7].nest.ed == "hi", receipts[7].nest.ed);
|
||||
todo(receipts[8] == NaN, receipts[8]);
|
||||
todo(receipts[9] == Infinity, receipts[9]);
|
||||
|
||||
next();
|
||||
};
|
||||
}
|
||||
var receipts = [
|
||||
"a",
|
||||
0,
|
||||
true,
|
||||
false,
|
||||
null,
|
||||
undefined,
|
||||
{ prop: 1 },
|
||||
{ nest: { ed: "hi" } },
|
||||
NaN,
|
||||
Infinity,
|
||||
];
|
||||
|
||||
function uninstall_super_crazy(next) {
|
||||
debug("in " + arguments.callee.name);
|
||||
var appURL = SERVERS['super_crazy'];
|
||||
uninstall(appURL, ok, function() { next(); });
|
||||
}
|
||||
confirmNextInstall();
|
||||
navigator.mozApps.install(url, { receipts: receipts }).onsuccess =
|
||||
function onInstall() {
|
||||
is(this.result.receipts[0], "a", "receipts[0]");
|
||||
is(this.result.receipts[1], 0, "receipts[1]");
|
||||
is(this.result.receipts[2], true, "receipts[2]");
|
||||
is(this.result.receipts[3], false, "receipts[3]");
|
||||
is(this.result.receipts[4], null, "receipts[4]");
|
||||
is(this.result.receipts[5], undefined, "receipts[5]");
|
||||
is(this.result.receipts[6].prop, 1, "receipts[6].prop");
|
||||
is(this.result.receipts[7].nest.ed, "hi", "receipts[7].nest.ed");
|
||||
todo_is(this.result.receipts[8], NaN, "receipts[8]");
|
||||
todo_is(this.result.receipts[9], Infinity, "receipts[9]");
|
||||
|
||||
</script>
|
||||
this.result.uninstall().onsuccess = function onUninstall() {
|
||||
SimpleTest.finish();
|
||||
}
|
||||
};
|
||||
|
||||
</script>
|
||||
</window>
|
||||
|
||||
|
|
|
@ -1,59 +1,37 @@
|
|||
<?xml version="1.0"?>
|
||||
|
||||
<!-- Any copyright is dedicated to the Public Domain.
|
||||
- http://creativecommons.org/publicdomain/zero/1.0/ -->
|
||||
|
||||
<?xml-stylesheet type="text/css" href="chrome://global/skin"?>
|
||||
<?xml-stylesheet type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"?>
|
||||
|
||||
<!-- Any copyright is dedicated to the Public Domain.
|
||||
- http://creativecommons.org/publicdomain/zero/1.0/
|
||||
- https://bugzilla.mozilla.org/show_bug.cgi?id=741549
|
||||
-->
|
||||
|
||||
<window title="Mozilla Bug 741549"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
||||
<script type="application/javascript" src="chrome://mochikit/content/chrome-harness.js"></script>
|
||||
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||
title="Mozilla Bug 741549">
|
||||
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
|
||||
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/>
|
||||
<script type="application/javascript" src="apphelper.js"/>
|
||||
<script type="application/javascript" src="jshelper.js"/>
|
||||
<script type="application/javascript" src="head.js"/>
|
||||
<!-- test results are displayed in the html:body -->
|
||||
<body xmlns="http://www.w3.org/1999/xhtml">
|
||||
<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=741549"
|
||||
target="_blank">Mozilla Bug 741549</a>
|
||||
</body>
|
||||
|
||||
<script>
|
||||
<script>
|
||||
|
||||
steps = [get_installed_returns_nothing, install_bom, uninstall_bom, tearDown];
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
runAll(steps);
|
||||
var url = "http://test/chrome/dom/tests/mochitest/webapps/apps/utf8.webapp";
|
||||
|
||||
function get_installed_returns_nothing(next) {
|
||||
debug("in " + arguments.callee.name);
|
||||
navigator.mozApps.getInstalled().onsuccess = function() {
|
||||
is(this.result.length, 0, "should get no installed app");
|
||||
next();
|
||||
};
|
||||
}
|
||||
confirmNextInstall();
|
||||
navigator.mozApps.install(url, null).onsuccess = function onInstall() {
|
||||
is(this.result.manifest.name, "TheBOM ゲゴケ゚セニツ゚ヅヂチ", "manifest.name");
|
||||
is(this.result.manifest.description, "This App is THE BOM, yo. ヅヂチ",
|
||||
"manifest.description");
|
||||
|
||||
function install_bom(next) {
|
||||
debug("in " + arguments.callee.name);
|
||||
var appURL = SERVERS['manifest_with_bom'];
|
||||
var pending = navigator.mozApps.install(appURL, null);
|
||||
pending.onsuccess = function() {
|
||||
var name = pending.result.manifest.name;
|
||||
var description = pending.result.manifest.description;
|
||||
ok(name == "TheBOM ゲゴケ゚セニツ゚ヅヂチ", name);
|
||||
ok(description == "This App is THE BOM, yo. ヅヂチ", description);
|
||||
next();
|
||||
};
|
||||
}
|
||||
|
||||
function uninstall_bom(next) {
|
||||
debug("in " + arguments.callee.name);
|
||||
var appURL = SERVERS['manifest_with_bom'];
|
||||
uninstall(appURL, ok, function() { next(); });
|
||||
}
|
||||
|
||||
</script>
|
||||
this.result.uninstall().onsuccess = function onUninstall() {
|
||||
SimpleTest.finish();
|
||||
}
|
||||
};
|
||||
|
||||
</script>
|
||||
</window>
|
||||
|
||||
|
|
|
@ -1,46 +1,54 @@
|
|||
<?xml version="1.0"?>
|
||||
|
||||
<!-- Any copyright is dedicated to the Public Domain.
|
||||
- http://creativecommons.org/publicdomain/zero/1.0/ -->
|
||||
|
||||
<?xml-stylesheet type="text/css" href="chrome://global/skin"?>
|
||||
<?xml-stylesheet type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"?>
|
||||
|
||||
<!-- Any copyright is dedicated to the Public Domain.
|
||||
- http://creativecommons.org/publicdomain/zero/1.0/
|
||||
- https://bugzilla.mozilla.org/show_bug.cgi?id=741549
|
||||
-->
|
||||
|
||||
<window title="Mozilla Bug 741549"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
||||
<script type="application/javascript" src="chrome://mochikit/content/chrome-harness.js"></script>
|
||||
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||
title="Mozilla Bug 741549">
|
||||
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
|
||||
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/>
|
||||
<script type="application/javascript" src="apphelper.js"/>
|
||||
<script type="application/javascript" src="jshelper.js"/>
|
||||
<script type="application/javascript" src="head.js"/>
|
||||
<!-- test results are displayed in the html:body -->
|
||||
<body xmlns="http://www.w3.org/1999/xhtml">
|
||||
<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=741549"
|
||||
target="_blank">Mozilla Bug 741549</a>
|
||||
</body>
|
||||
|
||||
<script type="text/javascript">
|
||||
<![CDATA[
|
||||
<script>
|
||||
|
||||
var expectedMethods = ['navigator.mozApps.QueryInterface',
|
||||
'navigator.mozApps.getInstalled',
|
||||
'navigator.mozApps.getSelf',
|
||||
'navigator.mozApps.install',
|
||||
'navigator.mozApps.installPackage',
|
||||
'navigator.mozApps.mgmt.QueryInterface',
|
||||
'navigator.mozApps.mgmt.getAll',
|
||||
'navigator.mozApps.mgmt.getNotInstalled'];
|
||||
var actualMethods = [];
|
||||
var props = {
|
||||
QueryInterface: "function",
|
||||
getInstalled: "function",
|
||||
getSelf: "function",
|
||||
install: "function",
|
||||
installPackage: "function",
|
||||
mgmt: "object",
|
||||
};
|
||||
|
||||
actualMethods = actualMethods.concat(iterateMethods("navigator.mozApps.", navigator.mozApps, ['setApplicationChooser', 'setRepoOrigin', 'setMockResponse']));
|
||||
actualMethods = actualMethods.concat(iterateMethods("navigator.mozApps.mgmt.", navigator.mozApps.mgmt));
|
||||
actualMethods = actualMethods.sort();
|
||||
ok(JSON.stringify(actualMethods) == JSON.stringify(expectedMethods), actualMethods);
|
||||
tearDown();
|
||||
]]>
|
||||
isDeeply([p for (p in navigator.mozApps)].sort(), Object.keys(props).sort(),
|
||||
"navigator.mozApps has only the expected properties");
|
||||
|
||||
</script>
|
||||
for (var p in props) {
|
||||
is(typeof navigator.mozApps[p], props[p], "typeof " + p);
|
||||
}
|
||||
|
||||
var mgmtProps = {
|
||||
QueryInterface: "function",
|
||||
getAll: "function",
|
||||
getNotInstalled: "function",
|
||||
oninstall: "object",
|
||||
onuninstall: "object",
|
||||
};
|
||||
|
||||
isDeeply([p for (p in navigator.mozApps.mgmt)].sort(),
|
||||
Object.keys(mgmtProps).sort(),
|
||||
"navigator.mozApps.mgmt has only the expected properties");
|
||||
|
||||
for (var p in mgmtProps) {
|
||||
is(typeof navigator.mozApps.mgmt[p], mgmtProps[p], "typeof mgmt." + p);
|
||||
}
|
||||
|
||||
</script>
|
||||
</window>
|
||||
|
||||
|
|
|
@ -73,7 +73,7 @@ SpecialPowers.setBoolPref('browser.mozApps.installer.dry_run', true);
|
|||
permManager.addFromPrincipal(window.document.nodePrincipal, "webapps-manage",
|
||||
Ci.nsIPermissionManager.ALLOW_ACTION);
|
||||
|
||||
var gManifestURL = "http://www.example.com:80/chrome/dom/tests/mochitest/webapps/apps/super_crazy.webapp";
|
||||
var gManifestURL = "http://www.example.com:80/chrome/dom/tests/mochitest/webapps/apps/basic.webapp";
|
||||
|
||||
confirmNextInstall();
|
||||
|
||||
|
|
|
@ -781,6 +781,9 @@ SimpleTest._deepCheck = function (e1, e2, stack, seen) {
|
|||
ok = SimpleTest._eqArray(e1, e2, stack, seen);
|
||||
} else if (typeof e1 == "object" && typeof e2 == "object") {
|
||||
ok = SimpleTest._eqAssoc(e1, e2, stack, seen);
|
||||
} else if (typeof e1 == "number" && typeof e2 == "number"
|
||||
&& isNaN(e1) && isNaN(e2)) {
|
||||
ok = true;
|
||||
} else {
|
||||
// If we get here, they're not the same (function references must
|
||||
// always simply reference the same function).
|
||||
|
|
Загрузка…
Ссылка в новой задаче