Files
palemoon27/toolkit/devtools/commandline/test/browser_cmd_screenshot.js
T
roytam1 45b8007f3d import changes from `dev' branch of rmottola/Arctic-Fox:
- Bug 1150717 - Test request with no params in the Network Monitor. r=brings (a60e9e8d9)
- Bug 1168077 - Remove remaining spidermonkey js specific syntax from browser/devtools; r=miker (c98f20c30)
- Bug 1168125 - Fix existing tests, r=jsantell (b1dfa101e)
- Bug 1169439 - Pull out marker definitions into its own file, and move formatter and collapse functions into marker-utils. r=vp (17eb24ab3)
- Bug 1173654 - Part 1: Add logging methods for SurfaceType and ImageFormat. r=Bas (22f2fa019)
- Bug 1169125 - Part 1: Allow sending any DataSourceSurface-backed image over WebRTC and fix failure cases. r=bwc (1fb0def92)
- Bug 1169125 - Part 2: Use UniquePtr for scoped delete of yuv data in MediaPipeline. r=bwc (cdb79e201)
- Bug 1173654 - Part 2: Use namespaces in MediaPipeline.cpp. r=bwc (311696260)
- Bug 1173654 - Part 3: Attempt to GetDataSurface() and convert if sending pure I420 fails. r=bwc, r=jesup (58520b820)
- Bug 1173654 - Part 4: Add detailed logging and asserts to MediaPipeline::ProcessVideoChunk. r=bwc (ba08ae5bc)
- Bug 1155089 - Part 1: Reset |TrackID| for MediaPipelineTransmit::PipelineListener on replaceTrack(). r=bwc (304fb8703)
- adapted Bug 1142688 - Wait for actual audio data on remote side before checking audio sanity. r=jesup,padenot (479f6356c)
- Bug 858927 - Move the mozilla::TimeStamp into mozglue. r=glandium (751938e09)
- Bug 1166559 - Add documentation for ProfileTimelineMarkers from a dev tools perspective. r=fitzgen (ed1563dfb)
- Bug 1141614 - Part 4: Expose cycle collection markers in the devtools frontend; r=jsantell (2eb830de7)
2021-07-30 11:25:34 +08:00

177 lines
4.7 KiB
JavaScript

/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
// Test that screenshot command works properly
const TEST_URI = "http://example.com/browser/browser/devtools/commandline/" +
"test/browser_cmd_screenshot.html";
let FileUtils = (Cu.import("resource://gre/modules/FileUtils.jsm", {})).FileUtils;
function test() {
return Task.spawn(spawnTest).then(finish, helpers.handleError);
}
function* spawnTest() {
waitForExplicitFinish();
info("RUN TEST: non-private window");
let normWin = yield addWindow({ private: false });
yield addTabWithToolbarRunTests(normWin);
normWin.close();
info("RUN TEST: private window");
let pbWin = yield addWindow({ private: true });
yield addTabWithToolbarRunTests(pbWin);
pbWin.close();
}
function* addTabWithToolbarRunTests(win) {
let options = yield helpers.openTab(TEST_URI, { chromeWindow: win });
yield helpers.openToolbar(options);
// Test input status
yield helpers.audit(options, [
{
setup: 'screenshot',
check: {
input: 'screenshot',
markup: 'VVVVVVVVVV',
status: 'VALID',
args: {
}
},
},
{
setup: 'screenshot abc.png',
check: {
input: 'screenshot abc.png',
markup: 'VVVVVVVVVVVVVVVVVV',
status: 'VALID',
args: {
filename: { value: "abc.png"},
}
},
},
{
setup: 'screenshot --fullpage',
check: {
input: 'screenshot --fullpage',
markup: 'VVVVVVVVVVVVVVVVVVVVV',
status: 'VALID',
args: {
fullpage: { value: true},
}
},
},
{
setup: 'screenshot abc --delay 5',
check: {
input: 'screenshot abc --delay 5',
markup: 'VVVVVVVVVVVVVVVVVVVVVVVV',
status: 'VALID',
args: {
filename: { value: "abc"},
delay: { value: 5 },
}
},
},
{
setup: 'screenshot --selector img#testImage',
check: {
input: 'screenshot --selector img#testImage',
markup: 'VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV',
status: 'VALID',
},
},
]);
// Test capture to file
let file = FileUtils.getFile("TmpD", [ "TestScreenshotFile.png" ]);
yield helpers.audit(options, [
{
setup: 'screenshot ' + file.path,
check: {
args: {
filename: { value: "" + file.path },
fullpage: { value: false },
clipboard: { value: false },
chrome: { value: false },
},
},
exec: {
output: new RegExp("^Saved to "),
},
post: function() {
// Bug 849168: screenshot command tests fail in try but not locally
// ok(file.exists(), "Screenshot file exists");
if (file.exists()) {
file.remove(false);
}
}
},
]);
// Test capture to clipboard
let clipid = Ci.nsIClipboard;
let clip = Cc["@mozilla.org/widget/clipboard;1"].getService(clipid);
let trans = Cc["@mozilla.org/widget/transferable;1"]
.createInstance(Ci.nsITransferable);
trans.init(null);
trans.addDataFlavor("image/png");
yield helpers.audit(options, [
{
setup: 'screenshot --fullpage --clipboard',
check: {
args: {
fullpage: { value: true },
clipboard: { value: true },
chrome: { value: false },
},
},
exec: {
output: new RegExp("^Copied to clipboard.$"),
},
post: function() {
try {
clip.getData(trans, clipid.kGlobalClipboard);
let str = new Object();
let strLength = new Object();
trans.getTransferData("image/png", str, strLength);
ok(str.value, "screenshot exists");
ok(strLength.value > 0, "screenshot has length");
}
finally {
Services.prefs.setBoolPref("browser.privatebrowsing.keep_current_session", true);
// Recent PB changes to the test I'm modifying removed the 'pb'
// variable, but left this line in tact. This seems so obviously
// wrong that I'm leaving this in in case the analysis is wrong
// pb.privateBrowsingEnabled = true;
}
}
},
]);
yield helpers.closeToolbar(options);
yield helpers.closeTab(options);
}
function addWindow(windowOptions) {
return new Promise(resolve => {
let win = OpenBrowserWindow(windowOptions);
// This feels hacky, we should refactor it
whenDelayedStartupFinished(win, () => {
// Would like to get rid of this executeSoon, but without it the url
// (TEST_URI) provided in addTabWithToolbarRunTests hasn't loaded
executeSoon(() => {
resolve(win);
});
});
});
}