dom/tests/mochitest/webapps/test_install_app.xul

Thu, 15 Jan 2015 15:55:04 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 15:55:04 +0100
branch
TOR_BUG_9701
changeset 9
a63d609f5ebe
permissions
-rw-r--r--

Back out 97036ab72558 which inappropriately compared turds to third parties.

michael@0 1 <?xml version="1.0"?>
michael@0 2
michael@0 3 <!-- Any copyright is dedicated to the Public Domain.
michael@0 4 - http://creativecommons.org/publicdomain/zero/1.0/ -->
michael@0 5
michael@0 6 <?xml-stylesheet type="text/css" href="chrome://global/skin"?>
michael@0 7 <?xml-stylesheet type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"?>
michael@0 8
michael@0 9 <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
michael@0 10 title="Mozilla Bug 741549">
michael@0 11 <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
michael@0 12 <script type="application/javascript" src="head.js"/>
michael@0 13 <!-- test results are displayed in the html:body -->
michael@0 14 <body xmlns="http://www.w3.org/1999/xhtml">
michael@0 15 <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=741549"
michael@0 16 target="_blank">Mozilla Bug 741549</a><br/>
michael@0 17 <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=734294"
michael@0 18 target="_blank">Mozilla Bug 734294</a>
michael@0 19 </body>
michael@0 20
michael@0 21 <script>
michael@0 22 <![CDATA[
michael@0 23
michael@0 24 var url = "http://test/chrome/dom/tests/mochitest/webapps/apps/basic.webapp";
michael@0 25 var app;
michael@0 26
michael@0 27 var steps = [
michael@0 28 getInstalledReturnsNothing,
michael@0 29 install,
michael@0 30 getInstalledReturnsApp,
michael@0 31 getSelf,
michael@0 32 uninstall,
michael@0 33 ];
michael@0 34
michael@0 35 runAll(steps);
michael@0 36
michael@0 37 function getInstalledReturnsNothing(next) {
michael@0 38 navigator.mozApps.getInstalled().onsuccess = function() {
michael@0 39 is(this.result.length, 0, "getInstalled() returns nothing");
michael@0 40 next();
michael@0 41 };
michael@0 42 }
michael@0 43
michael@0 44 function install(next) {
michael@0 45 var beforehand = Date.now();
michael@0 46 const fuzzySpan = 250;
michael@0 47
michael@0 48 confirmNextInstall();
michael@0 49 navigator.mozApps.install(url, null).onsuccess = function onInstall() {
michael@0 50 app = this.result;
michael@0 51
michael@0 52 is(app.origin, "http://test", "origin");
michael@0 53 is(app.installOrigin, "chrome://mochitests", "install origin");
michael@0 54 ok(app.installTime + fuzzySpan >= beforehand, "install time is after install() call");
michael@0 55 ok(app.installTime <= Date.now() + fuzzySpan, "install time is before install success");
michael@0 56 is(app.manifestURL, url, "manifest URL");
michael@0 57 is(app.manifest.name, "Basic App", "manifest.name");
michael@0 58 is(app.manifest.installs_allowed_from, "*",
michael@0 59 "manifest.installs_allowed_from");
michael@0 60
michael@0 61 next();
michael@0 62 }
michael@0 63 }
michael@0 64
michael@0 65 function getInstalledReturnsApp(next) {
michael@0 66 navigator.mozApps.getInstalled().onsuccess = function onGetInstalled() {
michael@0 67 // Retrieve the app we just installed from the list of installed apps.
michael@0 68 var a = [a for (a of this.result) if (a.manifestURL == url)][0];
michael@0 69
michael@0 70 // Compare the values of the two app objects to make sure install()
michael@0 71 // and getInstalled() return identical objects.
michael@0 72 isDeeply(a, app, "getInstalled() returns app identical to install()");
michael@0 73
michael@0 74 next();
michael@0 75 };
michael@0 76 }
michael@0 77
michael@0 78 function getSelf(next) {
michael@0 79 navigator.mozApps.getSelf().onsuccess = function onGetSelf() {
michael@0 80 is(this.result, null, "getSelf() returns nothing (different origin)");
michael@0 81
michael@0 82 next();
michael@0 83 };
michael@0 84 }
michael@0 85
michael@0 86 function uninstall(next) {
michael@0 87 navigator.mozApps.mgmt.uninstall(app).onsuccess = function onUninstall() {
michael@0 88 // Try to retrieve the app we just uninstalled, to make sure it no longer
michael@0 89 // exists in the registry.
michael@0 90 navigator.mozApps.getInstalled().onsuccess = function onGetInstalled() {
michael@0 91 var a = [a for (a of this.result) if (a.manifestURL == url)][0];
michael@0 92 is(a, undefined, "getInstalled() returns nothing again after uninstall");
michael@0 93
michael@0 94 next();
michael@0 95 };
michael@0 96 };
michael@0 97 }
michael@0 98
michael@0 99 ]]>
michael@0 100 </script>
michael@0 101 </window>

mercurial