browser_resource_navigation.js (2332B)
1 /* 2 * Any copyright is dedicated to the Public Domain. 3 * http://creativecommons.org/publicdomain/zero/1.0/ 4 */ 5 6 "use strict"; 7 8 add_task(async function () { 9 info("Make sure navigation through links in resource:// pages work"); 10 11 await BrowserTestUtils.withNewTab( 12 { gBrowser, url: "resource://gre/" }, 13 async function (browser) { 14 // Following a directory link shall properly open the directory (bug 1224046) 15 await SpecialPowers.spawn(browser, [], function () { 16 let link = Array.prototype.filter.call( 17 content.document.getElementsByClassName("dir"), 18 function (element) { 19 let name = element.textContent; 20 // Depending whether resource:// is backed by jar: or file://, 21 // directories either have a trailing slash or they don't. 22 if (name.endsWith("/")) { 23 name = name.slice(0, -1); 24 } 25 return name == "components"; 26 } 27 )[0]; 28 // First ensure the link is in the viewport 29 link.scrollIntoView(); 30 // Then click on it. 31 link.click(); 32 }); 33 34 await BrowserTestUtils.browserLoaded( 35 browser, 36 undefined, 37 "resource://gre/components/" 38 ); 39 40 // Following the parent link shall properly open the parent (bug 1366180) 41 await SpecialPowers.spawn(browser, [], function () { 42 let link = content.document 43 .getElementById("UI_goUp") 44 .getElementsByTagName("a")[0]; 45 // The link should always be high enough in the page to be in the viewport. 46 link.click(); 47 }); 48 49 await BrowserTestUtils.browserLoaded( 50 browser, 51 undefined, 52 "resource://gre/" 53 ); 54 55 // Following a link to a given file shall properly open the file. 56 await SpecialPowers.spawn(browser, [], function () { 57 let link = Array.prototype.filter.call( 58 content.document.getElementsByClassName("file"), 59 function (element) { 60 return element.textContent == "greprefs.js"; 61 } 62 )[0]; 63 link.scrollIntoView(); 64 link.click(); 65 }); 66 67 await BrowserTestUtils.browserLoaded( 68 browser, 69 undefined, 70 "resource://gre/greprefs.js" 71 ); 72 73 ok(true, "Got to the end of the test!"); 74 } 75 ); 76 });