mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-10-26 00:57:30 +09:00
Bug 1341589 - Test TriggeringPrincipal on history entry for view-source loads
This commit is contained in:
parent
582f93fe09
commit
db41bf152a
3 changed files with 57 additions and 0 deletions
|
|
@ -1,5 +1,6 @@
|
||||||
[DEFAULT]
|
[DEFAULT]
|
||||||
support-files =
|
support-files =
|
||||||
|
dummy_page.html
|
||||||
favicon_bug655270.ico
|
favicon_bug655270.ico
|
||||||
file_bug234628-1-child.html
|
file_bug234628-1-child.html
|
||||||
file_bug234628-1.html
|
file_bug234628-1.html
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,50 @@
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
const TEST_PATH = getRootDirectory(gTestPath).replace("chrome://mochitests/content", "http://example.com");
|
||||||
|
const HTML_URI = TEST_PATH + "dummy_page.html";
|
||||||
|
const VIEW_SRC_URI = "view-source:" + HTML_URI;
|
||||||
|
|
||||||
|
add_task(function*() {
|
||||||
|
info("load baseline html in new tab");
|
||||||
|
yield BrowserTestUtils.withNewTab(HTML_URI, function*(aBrowser) {
|
||||||
|
is(gBrowser.selectedBrowser.currentURI.spec, HTML_URI,
|
||||||
|
"sanity check to make sure html loaded");
|
||||||
|
|
||||||
|
info("right-click -> view-source of html");
|
||||||
|
let vSrcCtxtMenu = document.getElementById("contentAreaContextMenu");
|
||||||
|
let popupPromise = BrowserTestUtils.waitForEvent(vSrcCtxtMenu, "popupshown");
|
||||||
|
BrowserTestUtils.synthesizeMouseAtCenter("body", { type: "contextmenu", button: 2 }, aBrowser);
|
||||||
|
yield popupPromise;
|
||||||
|
let tabPromise = BrowserTestUtils.waitForNewTab(gBrowser, VIEW_SRC_URI);
|
||||||
|
let vSrcItem = vSrcCtxtMenu.getElementsByAttribute("id", "context-viewsource")[0];
|
||||||
|
vSrcItem.click();
|
||||||
|
vSrcCtxtMenu.hidePopup();
|
||||||
|
let tab = yield tabPromise;
|
||||||
|
is(gBrowser.selectedBrowser.currentURI.spec, VIEW_SRC_URI,
|
||||||
|
"loading view-source of html succeeded");
|
||||||
|
|
||||||
|
info ("load html file again before going .back()");
|
||||||
|
let loadPromise = BrowserTestUtils.browserLoaded(tab.linkedBrowser, false, HTML_URI);
|
||||||
|
yield ContentTask.spawn(tab.linkedBrowser, HTML_URI, HTML_URI => {
|
||||||
|
content.document.location = HTML_URI;
|
||||||
|
});
|
||||||
|
yield loadPromise;
|
||||||
|
is(gBrowser.selectedBrowser.currentURI.spec, HTML_URI,
|
||||||
|
"loading html another time succeeded");
|
||||||
|
|
||||||
|
info("click .back() to view-source of html again and make sure the history entry has a triggeringPrincipal");
|
||||||
|
let backCtxtMenu = document.getElementById("contentAreaContextMenu");
|
||||||
|
popupPromise = BrowserTestUtils.waitForEvent(backCtxtMenu, "popupshown");
|
||||||
|
BrowserTestUtils.synthesizeMouseAtCenter("body", { type: "contextmenu", button: 2 }, aBrowser);
|
||||||
|
yield popupPromise;
|
||||||
|
loadPromise = BrowserTestUtils.browserLoaded(tab.linkedBrowser, false, VIEW_SRC_URI);
|
||||||
|
let backItem = backCtxtMenu.getElementsByAttribute("id", "context-back")[0];
|
||||||
|
backItem.click();
|
||||||
|
backCtxtMenu.hidePopup();
|
||||||
|
yield loadPromise;
|
||||||
|
is(gBrowser.selectedBrowser.currentURI.spec, VIEW_SRC_URI,
|
||||||
|
"clicking .back() to view-source of html succeeded");
|
||||||
|
|
||||||
|
yield BrowserTestUtils.removeTab(tab);
|
||||||
|
});
|
||||||
|
});
|
||||||
6
docshell/test/browser/dummy_page.html
Normal file
6
docshell/test/browser/dummy_page.html
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
<html>
|
||||||
|
<head> <meta charset="utf-8"> </head>
|
||||||
|
<body>
|
||||||
|
just a dummy html file
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
Loading…
Add table
Add a link
Reference in a new issue