1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/downloads/tests/test_downloads_navigator_object.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,75 @@ 1.4 +<!DOCTYPE html> 1.5 +<html> 1.6 +<!-- 1.7 +https://bugzilla.mozilla.org/show_bug.cgi?id=938023 1.8 +--> 1.9 +<head> 1.10 + <title>Test for Bug 938023 Downloads API</title> 1.11 + <script type="text/javascript" src="/MochiKit/MochiKit.js"></script> 1.12 + <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> 1.13 + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> 1.14 +</head> 1.15 +<body> 1.16 + 1.17 +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=938023">Mozilla Bug 938023</a> 1.18 +<p id="display"></p> 1.19 +<div id="content" style="display: none"> 1.20 +<iframe></iframe> 1.21 +</div> 1.22 +<pre id="test"> 1.23 +<script class="testbody" type="text/javascript;version=1.7"> 1.24 + 1.25 +SimpleTest.waitForExplicitFinish(); 1.26 + 1.27 +var index = -1; 1.28 + 1.29 +function next() { 1.30 + index += 1; 1.31 + if (index >= steps.length) { 1.32 + ok(false, "Shouldn't get here!"); 1.33 + return; 1.34 + } 1.35 + try { 1.36 + steps[index](); 1.37 + } catch(ex) { 1.38 + ok(false, "Caught exception", ex); 1.39 + } 1.40 +} 1.41 + 1.42 +var steps = [ 1.43 + // Start by setting the pref to true. 1.44 + function() { 1.45 + SpecialPowers.pushPrefEnv({ 1.46 + set: [["dom.mozDownloads.enabled", true]] 1.47 + }, next); 1.48 + }, 1.49 + 1.50 + function() { 1.51 + SpecialPowers.pushPermissions([ 1.52 + {type: "downloads", allow: 0, context: document} 1.53 + ], function() { 1.54 + ise(frames[0].navigator.mozDownloadManager, null, "navigator.mozDownloadManager is null when the page doesn't have permissions"); 1.55 + next(); 1.56 + }); 1.57 + }, 1.58 + 1.59 + function() { 1.60 + SpecialPowers.pushPrefEnv({ 1.61 + set: [["dom.mozDownloads.enabled", false]] 1.62 + }, function() { 1.63 + ise(navigator.mozDownloadManager, undefined, "navigator.mozDownloadManager is undefined"); 1.64 + next(); 1.65 + }); 1.66 + }, 1.67 + 1.68 + function() { 1.69 + SimpleTest.finish(); 1.70 + } 1.71 +]; 1.72 + 1.73 +next(); 1.74 + 1.75 +</script> 1.76 +</pre> 1.77 +</body> 1.78 +</html>