dom/downloads/tests/test_downloads_navigator_object.html

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 <!DOCTYPE html>
     2 <html>
     3 <!--
     4 https://bugzilla.mozilla.org/show_bug.cgi?id=938023
     5 -->
     6 <head>
     7   <title>Test for Bug 938023 Downloads API</title>
     8   <script type="text/javascript" src="/MochiKit/MochiKit.js"></script>
     9   <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
    10   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
    11 </head>
    12 <body>
    14 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=938023">Mozilla Bug 938023</a>
    15 <p id="display"></p>
    16 <div id="content" style="display: none">
    17 <iframe></iframe>
    18 </div>
    19 <pre id="test">
    20 <script class="testbody" type="text/javascript;version=1.7">
    22 SimpleTest.waitForExplicitFinish();
    24 var index = -1;
    26 function next() {
    27   index += 1;
    28   if (index >= steps.length) {
    29     ok(false, "Shouldn't get here!");
    30     return;
    31   }
    32   try {
    33     steps[index]();
    34   } catch(ex) {
    35     ok(false, "Caught exception", ex);
    36   }
    37 }
    39 var steps = [
    40   // Start by setting the pref to true.
    41   function() {
    42     SpecialPowers.pushPrefEnv({
    43       set: [["dom.mozDownloads.enabled", true]]
    44     }, next);
    45   },
    47   function() {
    48     SpecialPowers.pushPermissions([
    49       {type: "downloads", allow: 0, context: document}
    50     ], function() {
    51       ise(frames[0].navigator.mozDownloadManager, null, "navigator.mozDownloadManager is null when the page doesn't have permissions");
    52       next();
    53     });
    54   },
    56   function() {
    57     SpecialPowers.pushPrefEnv({
    58       set: [["dom.mozDownloads.enabled", false]]
    59     }, function() {
    60       ise(navigator.mozDownloadManager, undefined, "navigator.mozDownloadManager is undefined");
    61       next();
    62     });
    63   },
    65   function() {
    66     SimpleTest.finish();
    67   }
    68 ];
    70 next();
    72 </script>
    73 </pre>
    74 </body>
    75 </html>

mercurial