toolkit/mozapps/update/tests/marionette/update_test_ota_simple.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 /* Any copyright is dedicated to the Public Domain.
     2  * http://creativecommons.org/publicdomain/zero/1.0/ */
     4 function testForceCheck() {
     5   addChromeEventListener("update-available", function(evt) {
     6     let update = evt.detail;
     7     is(update.displayVersion, "99.0");
     8     is(update.isOSUpdate, false);
     9     statusSettingIs("check-complete", testDownload);
    10     return true;
    11   });
    12   sendContentEvent("force-update-check");
    13 }
    15 function testDownload() {
    16   let gotStarted = false, gotProgress = false, gotStopped = false;
    17   let progress = 0, total = 0;
    19   addChromeEventListener("update-download-started", function(evt) {
    20     gotStarted = true;
    21     return true;
    22   });
    23   addChromeEventListener("update-download-progress", function(evt) {
    24     progress = evt.detail.progress;
    25     total = evt.detail.total;
    26     gotProgress = true;
    27     if (total == progress) {
    28       ok(gotStarted);
    29       return true;
    30     }
    31     return false;
    32   });
    33   addChromeEventListener("update-download-stopped", function(evt) {
    34     is(evt.detail.paused, false);
    35     gotStopped = true;
    36     ok(gotStarted);
    37     ok(gotProgress);
    38     return true;
    39   });
    40   addChromeEventListener("update-downloaded", function(evt) {
    41     ok(gotStarted);
    42     ok(gotProgress);
    43     ok(gotStopped);
    44     is(progress, total);
    45     return true;
    46   });
    47   addChromeEventListener("update-prompt-apply", function(evt) {
    48     let update = evt.detail;
    49     is(update.displayVersion, "99.0");
    50     is(update.isOSUpdate, false);
    51     cleanUp();
    52   });
    53   sendContentEvent("update-available-result", {
    54     result: "download"
    55   });
    56 }
    58 function testApplied() {
    59   let updateFile = Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsIFile);
    60   updateFile.initWithPath("/system/b2g/update_test/UpdateTestAddFile");
    61   ok(updateFile.exists());
    62   cleanUp();
    63 }
    65 // Update lifecycle callbacks
    66 function preUpdate() {
    67   testForceCheck();
    68 }
    70 function postUpdate() {
    71   testApplied();
    72 }

mercurial