3 const TEST_PATH = getRootDirectory(gTestPath).replace(
4 "chrome://mochitests/content",
7 const HTML_URI = TEST_PATH + "dummy_page.html";
8 const VIEW_SRC_URI = "view-source:" + HTML_URI;
10 add_task(async function() {
11 await SpecialPowers.pushPrefEnv({
12 set: [["browser.navigation.requireUserInteraction", false]],
15 info("load baseline html in new tab");
16 await BrowserTestUtils.withNewTab(HTML_URI, async function(aBrowser) {
18 gBrowser.selectedBrowser.currentURI.spec,
20 "sanity check to make sure html loaded"
23 info("right-click -> view-source of html");
24 let vSrcCtxtMenu = document.getElementById("contentAreaContextMenu");
25 let popupPromise = BrowserTestUtils.waitForEvent(
29 BrowserTestUtils.synthesizeMouseAtCenter(
31 { type: "contextmenu", button: 2 },
35 let tabPromise = BrowserTestUtils.waitForNewTab(gBrowser, VIEW_SRC_URI);
36 let vSrcItem = vSrcCtxtMenu.getElementsByAttribute(
41 vSrcCtxtMenu.hidePopup();
42 let tab = await tabPromise;
44 gBrowser.selectedBrowser.currentURI.spec,
46 "loading view-source of html succeeded"
49 info("load html file again before going .back()");
50 let loadPromise = BrowserTestUtils.browserLoaded(
55 await SpecialPowers.spawn(tab.linkedBrowser, [HTML_URI], HTML_URI => {
56 content.document.location = HTML_URI;
60 gBrowser.selectedBrowser.currentURI.spec,
62 "loading html another time succeeded"
66 "click .back() to view-source of html again and make sure the history entry has a triggeringPrincipal"
68 let backCtxtMenu = document.getElementById("contentAreaContextMenu");
69 popupPromise = BrowserTestUtils.waitForEvent(backCtxtMenu, "popupshown");
70 BrowserTestUtils.synthesizeMouseAtCenter(
72 { type: "contextmenu", button: 2 },
76 loadPromise = BrowserTestUtils.waitForContentEvent(
80 let backItem = backCtxtMenu.getElementsByAttribute("id", "context-back")[0];
82 backCtxtMenu.hidePopup();
85 gBrowser.selectedBrowser.currentURI.spec,
87 "clicking .back() to view-source of html succeeded"
90 BrowserTestUtils.removeTab(tab);