browser_alternate_fixup_middle_click_link.js (1731B)
1 /* Any copyright is dedicated to the Public Domain. 2 http://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 "use strict"; 5 6 /** 7 * Check that we don't do alternate fixup when users middle-click 8 * broken links in the content document. 9 */ 10 add_task(async function test_alt_fixup_middle_click() { 11 await BrowserTestUtils.withNewTab("about:blank", async browser => { 12 await SpecialPowers.spawn(browser, [], () => { 13 let link = content.document.createElement("a"); 14 // eslint-disable-next-line @microsoft/sdl/no-insecure-url 15 link.href = "http://example/foo"; 16 link.textContent = "Me, me, click me!"; 17 content.document.body.append(link); 18 }); 19 let newTabPromise = BrowserTestUtils.waitForNewTab( 20 gBrowser, 21 /* wantLoad = */ null, 22 /* waitForLoad = */ true, 23 /* waitForAnyTab = */ false, 24 /* maybeErrorPage = */ true 25 ); 26 await BrowserTestUtils.synthesizeMouseAtCenter( 27 "a[href]", 28 { button: 1 }, 29 browser 30 ); 31 let tab = await newTabPromise; 32 let { browsingContext } = tab.linkedBrowser; 33 // TBH, if the test fails, we probably force-crash because we try to reach 34 // *www.* example.com, which isn't proxied by the test infrastructure so 35 // will forcibly abort the test. But we need some asserts so they might as 36 // well be meaningful: 37 is( 38 tab.linkedBrowser.currentURI.spec, 39 // eslint-disable-next-line @microsoft/sdl/no-insecure-url 40 "http://example/foo", 41 "URL for tab should be correct." 42 ); 43 44 ok( 45 browsingContext.currentWindowGlobal.documentURI.spec.startsWith( 46 "about:neterror" 47 ), 48 "Should be showing error page." 49 ); 50 BrowserTestUtils.removeTab(tab); 51 }); 52 });