browser_headless_screenshot_3.js (1508B)
1 "use strict"; 2 3 add_task(async function () { 4 const cwdScreenshotPath = PathUtils.join( 5 Services.dirsvc.get("CurWorkD", Ci.nsIFile).path, 6 "screenshot.png" 7 ); 8 9 // Test invalid URL arguments (either no argument or too many arguments). 10 await testFileCreationNegative(["-screenshot"], cwdScreenshotPath); 11 await testFileCreationNegative( 12 [ 13 "http://mochi.test:8888/browser/browser/components/shell/test/headless.html", 14 "http://mochi.test:8888/headless.html", 15 "-screenshot", 16 ], 17 cwdScreenshotPath 18 ); 19 20 // Test all four basic variations of the "window-size" argument. 21 await testFileCreationPositive( 22 [ 23 "-url", 24 "http://mochi.test:8888/browser/browser/components/shell/test/headless.html", 25 "-screenshot", 26 "-window-size", 27 "800", 28 ], 29 cwdScreenshotPath 30 ); 31 await testFileCreationPositive( 32 [ 33 "-url", 34 "http://mochi.test:8888/browser/browser/components/shell/test/headless.html", 35 "-screenshot", 36 "-window-size=800", 37 ], 38 cwdScreenshotPath 39 ); 40 await testFileCreationPositive( 41 [ 42 "-url", 43 "http://mochi.test:8888/browser/browser/components/shell/test/headless.html", 44 "-screenshot", 45 "--window-size", 46 "800", 47 ], 48 cwdScreenshotPath 49 ); 50 await testFileCreationPositive( 51 [ 52 "-url", 53 "http://mochi.test:8888/browser/browser/components/shell/test/headless.html", 54 "-screenshot", 55 "--window-size=800", 56 ], 57 cwdScreenshotPath 58 ); 59 });