|
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> |
|
13 |
|
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"> |
|
21 |
|
22 SimpleTest.waitForExplicitFinish(); |
|
23 |
|
24 var index = -1; |
|
25 |
|
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 } |
|
38 |
|
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 }, |
|
46 |
|
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 }, |
|
55 |
|
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 }, |
|
64 |
|
65 function() { |
|
66 SimpleTest.finish(); |
|
67 } |
|
68 ]; |
|
69 |
|
70 next(); |
|
71 |
|
72 </script> |
|
73 </pre> |
|
74 </body> |
|
75 </html> |