browser_pageinfo_image_info.js (1938B)
1 /** 2 * Any copyright is dedicated to the Public Domain. 3 * http://creativecommons.org/publicdomain/zero/1.0/ 4 */ 5 6 const URI = 7 "data:text/html," + 8 "<style type='text/css'>%23test-image,%23not-test-image {background-image: url('about:logo?c');}</style>" + 9 "<img src='about:logo?b' height=300 width=350 alt=2 id='not-test-image'>" + 10 "<img src='about:logo?b' height=300 width=350 alt=2>" + 11 "<img src='about:logo?a' height=200 width=250>" + 12 "<img src='about:logo?b' height=200 width=250 alt=1>" + 13 "<img src='about:logo?b' height=100 width=150 alt=2 id='test-image'>"; 14 15 add_task(async function () { 16 let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, URI); 17 let browser = tab.linkedBrowser; 18 19 let imageInfo = await SpecialPowers.spawn(browser, [], async () => { 20 let testImg = content.document.getElementById("test-image"); 21 22 return { 23 src: testImg.src, 24 currentSrc: testImg.currentSrc, 25 width: testImg.width, 26 height: testImg.height, 27 imageText: testImg.title || testImg.alt, 28 }; 29 }); 30 31 let pageInfo = BrowserCommands.pageInfo( 32 browser.currentURI.spec, 33 "mediaTab", 34 imageInfo 35 ); 36 await BrowserTestUtils.waitForEvent(pageInfo, "page-info-mediapreview-load"); 37 38 let mediaBrowser = pageInfo.document.getElementById("mediaBrowser"); 39 let pageInfoImg = await SpecialPowers.spawn(mediaBrowser, [], () => { 40 let previewImg = content.document.querySelector("img"); 41 42 return { 43 src: previewImg.src, 44 width: previewImg.width, 45 height: previewImg.height, 46 }; 47 }); 48 Assert.equal( 49 pageInfoImg.src, 50 imageInfo.src, 51 "selected image has the correct source" 52 ); 53 Assert.equal( 54 pageInfoImg.width, 55 imageInfo.width, 56 "selected image has the correct width" 57 ); 58 Assert.equal( 59 pageInfoImg.height, 60 imageInfo.height, 61 "selected image has the correct height" 62 ); 63 pageInfo.close(); 64 BrowserTestUtils.removeTab(tab); 65 });