From 5f8de423f190bbb79a62f804151bc24824fa32d8 Mon Sep 17 00:00:00 2001 From: "Matt A. Tobin" Date: Fri, 2 Feb 2018 04:16:08 -0500 Subject: Add m-esr52 at 52.6.0 --- .../base/content/test/general/browser_bug575561.js | 97 ++++++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100644 browser/base/content/test/general/browser_bug575561.js (limited to 'browser/base/content/test/general/browser_bug575561.js') diff --git a/browser/base/content/test/general/browser_bug575561.js b/browser/base/content/test/general/browser_bug575561.js new file mode 100644 index 000000000..b6d17a447 --- /dev/null +++ b/browser/base/content/test/general/browser_bug575561.js @@ -0,0 +1,97 @@ +requestLongerTimeout(2); + +const TEST_URL = "http://example.com/browser/browser/base/content/test/general/app_bug575561.html"; + +add_task(function*() { + SimpleTest.requestCompleteLog(); + + // Pinned: Link to the same domain should not open a new tab + // Tests link to http://example.com/browser/browser/base/content/test/general/dummy_page.html + yield testLink(0, true, false); + // Pinned: Link to a different subdomain should open a new tab + // Tests link to http://test1.example.com/browser/browser/base/content/test/general/dummy_page.html + yield testLink(1, true, true); + + // Pinned: Link to a different domain should open a new tab + // Tests link to http://example.org/browser/browser/base/content/test/general/dummy_page.html + yield testLink(2, true, true); + + // Not Pinned: Link to a different domain should not open a new tab + // Tests link to http://example.org/browser/browser/base/content/test/general/dummy_page.html + yield testLink(2, false, false); + + // Pinned: Targetted link should open a new tab + // Tests link to http://example.org/browser/browser/base/content/test/general/dummy_page.html with target="foo" + yield testLink(3, true, true); + + // Pinned: Link in a subframe should not open a new tab + // Tests link to http://example.org/browser/browser/base/content/test/general/dummy_page.html in subframe + yield testLink(0, true, false, true); + + // Pinned: Link to the same domain (with www prefix) should not open a new tab + // Tests link to http://www.example.com/browser/browser/base/content/test/general/dummy_page.html + yield testLink(4, true, false); + + // Pinned: Link to a data: URI should not open a new tab + // Tests link to data:text/html,Another Page + yield testLink(5, true, false); + + // Pinned: Link to an about: URI should not open a new tab + // Tests link to about:logo + yield testLink(function(doc) { + let link = doc.createElement("a"); + link.textContent = "Link to Mozilla"; + link.href = "about:logo"; + doc.body.appendChild(link); + return link; + }, true, false, false, "about:robots"); +}); + +var waitForPageLoad = Task.async(function*(browser, linkLocation) { + yield waitForDocLoadComplete(); + + is(browser.contentDocument.location.href, linkLocation, "Link should not open in a new tab"); +}); + +var waitForTabOpen = Task.async(function*() { + let event = yield promiseWaitForEvent(gBrowser.tabContainer, "TabOpen", true); + ok(true, "Link should open a new tab"); + + yield waitForDocLoadComplete(event.target.linkedBrowser); + yield Promise.resolve(); + + gBrowser.removeCurrentTab(); +}); + +var testLink = Task.async(function*(aLinkIndexOrFunction, pinTab, expectNewTab, testSubFrame, aURL = TEST_URL) { + let appTab = gBrowser.addTab(aURL, {skipAnimation: true}); + if (pinTab) + gBrowser.pinTab(appTab); + gBrowser.selectedTab = appTab; + + yield waitForDocLoadComplete(); + + let browser = appTab.linkedBrowser; + if (testSubFrame) + browser = browser.contentDocument.querySelector("iframe"); + + let link; + if (typeof aLinkIndexOrFunction == "function") { + link = aLinkIndexOrFunction(browser.contentDocument); + } else { + link = browser.contentDocument.querySelectorAll("a")[aLinkIndexOrFunction]; + } + + let promise; + if (expectNewTab) + promise = waitForTabOpen(); + else + promise = waitForPageLoad(browser, link.href); + + info("Clicking " + link.textContent); + link.click(); + + yield promise; + + gBrowser.removeTab(appTab); +}); -- cgit v1.2.3