dom/tests/mochitest/webapps/test_install_app.xul

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rw-r--r--

Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

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

mercurial