browser_markup_screenshot_node_iframe.js (1570B)
1 /* Any copyright is dedicated to the Public Domain. 2 http://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 "use strict"; 5 6 const exampleOrgDocument = `https://example.org/document-builder.sjs`; 7 const exampleComDocument = `https://example.com/document-builder.sjs`; 8 9 const TEST_URL = `${exampleOrgDocument}?html= 10 <iframe 11 src="${exampleOrgDocument}?html=<div style='width:30px;height:30px;background:rgb(255,0,0)'></div>" 12 id="same-origin"></iframe> 13 <iframe 14 src="${exampleComDocument}?html=<div style='width:25px;height:10px;background:rgb(0,255,0)'></div>" 15 id="remote"></iframe>`; 16 17 // Test that the "Screenshot Node" feature works with a node inside an iframe. 18 add_task(async function () { 19 const { inspector, toolbox } = await openInspectorForURL(encodeURI(TEST_URL)); 20 21 info("Select the red node"); 22 await selectNodeInFrames(["#same-origin", "div"], inspector); 23 24 info( 25 "Take a screenshot of the red div in the same origin iframe node and verify it looks as expected" 26 ); 27 const redScreenshot = await takeNodeScreenshot(inspector); 28 await assertSingleColorScreenshotImage(redScreenshot, 30, 30, { 29 r: 255, 30 g: 0, 31 b: 0, 32 }); 33 34 info("Select the green node"); 35 await selectNodeInFrames(["#remote", "div"], inspector); 36 info( 37 "Take a screenshot of the green div in the remote iframe node and verify it looks as expected" 38 ); 39 const greenScreenshot = await takeNodeScreenshot(inspector); 40 await assertSingleColorScreenshotImage(greenScreenshot, 25, 10, { 41 r: 0, 42 g: 255, 43 b: 0, 44 }); 45 await toolbox.destroy(); 46 });