summaryrefslogtreecommitdiffstats
path: root/browser/base/content/test/pageinfo/browser_pageinfo_images.js
diff options
context:
space:
mode:
Diffstat (limited to 'browser/base/content/test/pageinfo/browser_pageinfo_images.js')
-rw-r--r--browser/base/content/test/pageinfo/browser_pageinfo_images.js93
1 files changed, 93 insertions, 0 deletions
diff --git a/browser/base/content/test/pageinfo/browser_pageinfo_images.js b/browser/base/content/test/pageinfo/browser_pageinfo_images.js
new file mode 100644
index 0000000000..5cb4c79bf3
--- /dev/null
+++ b/browser/base/content/test/pageinfo/browser_pageinfo_images.js
@@ -0,0 +1,93 @@
+/* Check proper image url retrieval from all kinds of elements/styles */
+
+const TEST_PATH = getRootDirectory(gTestPath).replace(
+ "chrome://mochitests/content",
+ // eslint-disable-next-line @microsoft/sdl/no-insecure-url
+ "http://example.com"
+);
+
+add_task(async function test_all_images_mentioned() {
+ await BrowserTestUtils.withNewTab(
+ TEST_PATH + "all_images.html",
+ async function () {
+ let pageInfo = BrowserPageInfo(
+ gBrowser.selectedBrowser.currentURI.spec,
+ "mediaTab"
+ );
+ await BrowserTestUtils.waitForEvent(pageInfo, "page-info-init");
+
+ let imageTree = pageInfo.document.getElementById("imagetree");
+ let imageRowsNum = imageTree.view.rowCount;
+
+ ok(imageTree, "Image tree is null (media tab is broken)");
+
+ ok(
+ imageRowsNum == 7,
+ "Number of images listed: " + imageRowsNum + ", should be 7"
+ );
+
+ // Check that select all works
+ imageTree.focus();
+ ok(
+ !pageInfo.document.getElementById("cmd_copy").hasAttribute("disabled"),
+ "copy is enabled"
+ );
+ ok(
+ !pageInfo.document
+ .getElementById("cmd_selectAll")
+ .hasAttribute("disabled"),
+ "select all is enabled"
+ );
+ pageInfo.goDoCommand("cmd_selectAll");
+ is(imageTree.view.selection.count, 7, "all rows selected");
+
+ pageInfo.close();
+ }
+ );
+});
+
+add_task(async function test_view_image_info() {
+ await SpecialPowers.pushPrefEnv({
+ set: [["browser.menu.showViewImageInfo", true]],
+ });
+
+ await BrowserTestUtils.withNewTab(
+ TEST_PATH + "all_images.html",
+
+ async function (browser) {
+ let contextMenu = document.getElementById("contentAreaContextMenu");
+ let viewImageInfo = document.getElementById("context-viewimageinfo");
+
+ let imageInfo = await SpecialPowers.spawn(browser, [], async () => {
+ let testImg = content.document.querySelector("img");
+ return {
+ src: testImg.src,
+ };
+ });
+
+ await BrowserTestUtils.synthesizeMouseAtCenter(
+ "img",
+ { type: "contextmenu", button: 2 },
+ browser
+ );
+
+ await BrowserTestUtils.waitForEvent(contextMenu, "popupshown");
+
+ let promisePageInfoLoaded = BrowserTestUtils.domWindowOpened().then(win =>
+ BrowserTestUtils.waitForEvent(win, "page-info-init")
+ );
+
+ contextMenu.activateItem(viewImageInfo);
+
+ let pageInfo = (await promisePageInfoLoaded).target.ownerGlobal;
+ let pageInfoImg = pageInfo.document.getElementById("thepreviewimage");
+
+ Assert.equal(
+ pageInfoImg.src,
+ imageInfo.src,
+ "selected image is the correct"
+ );
+ await BrowserTestUtils.closeWindow(pageInfo);
+ }
+ );
+});