Bug 1938475 [Wayland] Fallback to monitor screen scale if we're missing wayland surfa...
[gecko.git] / security / manager / ssl / tests / mochitest / mixedcontent / test_bug383369.html
blobd9298cde3f5098a0ff767e630288c5ef6101d9cf
1 <!DOCTYPE HTML>
2 <html>
3 <head>
4 <title>Bug 383369 test</title>
5 <script src="/tests/SimpleTest/SimpleTest.js"></script>
6 <script type="text/javascript" src="mixedContentTest.js"></script>
7 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
9 <script class="testbody" type="text/javascript">
10 "use strict";
12 // We want to start this test from an insecure context
13 loadAsInsecure = true;
14 // We don't want to go through the navigation back/forward test
15 bypassNavigationTest = true;
17 async function runTest() {
18 let script = SpecialPowers.loadChromeScript(function() {
19 /* eslint-env mozilla/chrome-script */
20 // Force download to be w/o user assistance for our testing mime type
21 const mimeSvc = Cc["@mozilla.org/mime;1"].getService(Ci.nsIMIMEService);
22 let handlerInfo =
23 mimeSvc.getFromTypeAndExtension("application/x-auto-download", "auto");
24 handlerInfo.preferredAction = Ci.nsIHandlerInfo.saveToDisk;
25 handlerInfo.alwaysAskBeforeHandling = false;
26 handlerInfo.preferredApplicationHandler = null;
28 const handlerSvc = Cc["@mozilla.org/uriloader/handler-service;1"]
29 .getService(Ci.nsIHandlerService);
30 handlerSvc.store(handlerInfo);
32 let profileDir = Services.dirsvc.get("ProfDS", Ci.nsIFile);
33 profileDir.append("downloads");
35 let prefBranch = Services.prefs.getBranch("browser.download.");
37 prefBranch.setCharPref("dir", profileDir.path);
38 prefBranch.setBoolPref("useDownloadDir", true);
39 prefBranch.setIntPref("folderList", 2);
41 const { Downloads } =
42 ChromeUtils.importESModule("resource://gre/modules/Downloads.sys.mjs");
43 Downloads.getList(Downloads.PUBLIC).then(list => {
44 list.addView({
45 onDownloadAdded(aDownload) {
46 list.removeView(this);
47 aDownload.whenSucceeded().then(() => {
48 list.removeFinished();
49 sendAsyncMessage("navigate", "bug383369step2.html");
50 });
52 });
53 sendAsyncMessage("navigate", "download.auto");
54 }).catch(console.error);
55 });
56 script.addMessageListener("navigate", function(url) {
57 window.location = url;
58 });
61 async function afterNavigationTest() {}
63 testCleanUp = function cleanup() {
64 SpecialPowers.loadChromeScript(function() {
65 const mimeSvc = Cc["@mozilla.org/mime;1"].getService(Ci.nsIMIMEService);
66 let handlerInfo =
67 mimeSvc.getFromTypeAndExtension("application/x-auto-download", "auto");
69 const handlerSvc = Cc["@mozilla.org/uriloader/handler-service;1"]
70 .getService(Ci.nsIHandlerService);
71 handlerSvc.remove(handlerInfo);
73 let prefBranch = Services.prefs.getBranch("browser.download.");
75 const prefKeys = ["dir", "useDownloadDir", "folderList"];
76 for (let prefKey of prefKeys) {
77 if (prefBranch.prefHasUserValue(prefKey)) {
78 prefBranch.clearUserPref(prefKey);
81 });
84 </script>
85 </head>
87 <body>
88 </body>
89 </html>