mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 824253 - Intermittent browser_cmd_screenshot_perwindowpb.js; r=ehsan
This commit is contained in:
parent
fac43d8ca2
commit
dd69212e65
@ -11,6 +11,15 @@ let FileUtils = Cu.import("resource://gre/modules/FileUtils.jsm", {}).FileUtils;
|
|||||||
function test() {
|
function test() {
|
||||||
waitForExplicitFinish();
|
waitForExplicitFinish();
|
||||||
|
|
||||||
|
let windowsToClose = [];
|
||||||
|
Services.prefs.setIntPref("browser.startup.page", 0);
|
||||||
|
registerCleanupFunction(function() {
|
||||||
|
Services.prefs.clearUserPref("browser.startup.page");
|
||||||
|
windowsToClose.forEach(function(win) {
|
||||||
|
win.close();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
function testOnWindow(aPrivate, aCallback) {
|
function testOnWindow(aPrivate, aCallback) {
|
||||||
let win = OpenBrowserWindow({private: aPrivate});
|
let win = OpenBrowserWindow({private: aPrivate});
|
||||||
win.addEventListener("load", function onLoad() {
|
win.addEventListener("load", function onLoad() {
|
||||||
@ -20,29 +29,25 @@ function test() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
testOnWindow(false, function(win) {
|
testOnWindow(false, function(win) {
|
||||||
|
info("Testing on public window");
|
||||||
|
windowsToClose.push(win);
|
||||||
DeveloperToolbarTestPW.test(win, TEST_URI, [ testInput, testCapture ], null, function() {
|
DeveloperToolbarTestPW.test(win, TEST_URI, [ testInput, testCapture ], null, function() {
|
||||||
win.close();
|
|
||||||
testOnWindow(true, function(win) {
|
testOnWindow(true, function(win) {
|
||||||
executeSoon(function() {
|
info("Testing on private window");
|
||||||
DeveloperToolbarTestPW.test(win, TEST_URI, [ testInput, testCapture ], null, function() {
|
windowsToClose.push(win);
|
||||||
win.close();
|
DeveloperToolbarTestPW.test(win, TEST_URI, [ testInput, testCapture ], null, finish);
|
||||||
finish();
|
|
||||||
});
|
|
||||||
})
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function testInput(aWindow) {
|
function testInput(aWindow, aCallback) {
|
||||||
helpers_perwindowpb.setInput('screenshot');
|
helpers_perwindowpb.setInput('screenshot');
|
||||||
helpers_perwindowpb.check({
|
helpers_perwindowpb.check({
|
||||||
input: 'screenshot',
|
input: 'screenshot',
|
||||||
markup: 'VVVVVVVVVV',
|
markup: 'VVVVVVVVVV',
|
||||||
status: 'VALID',
|
status: 'VALID',
|
||||||
args: {
|
args: { }
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
helpers_perwindowpb.setInput('screenshot abc.png');
|
helpers_perwindowpb.setInput('screenshot abc.png');
|
||||||
@ -85,9 +90,11 @@ function testInput(aWindow) {
|
|||||||
selector: { value: aWindow.content.document.getElementById("testImage")},
|
selector: { value: aWindow.content.document.getElementById("testImage")},
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
aCallback();
|
||||||
}
|
}
|
||||||
|
|
||||||
function testCapture(aWindow) {
|
function testCapture(aWindow, aCallback) {
|
||||||
function checkTemporaryFile() {
|
function checkTemporaryFile() {
|
||||||
// Create a temporary file.
|
// Create a temporary file.
|
||||||
let gFile = FileUtils.getFile("TmpD", ["TestScreenshotFile.png"]);
|
let gFile = FileUtils.getFile("TmpD", ["TestScreenshotFile.png"]);
|
||||||
@ -100,6 +107,13 @@ function testCapture(aWindow) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let captureTest = 3;
|
||||||
|
function captureTestFinish() {
|
||||||
|
if (captureTest == 0) {
|
||||||
|
aCallback();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function checkClipboard() {
|
function checkClipboard() {
|
||||||
try {
|
try {
|
||||||
let clipid = Ci.nsIClipboard;
|
let clipid = Ci.nsIClipboard;
|
||||||
@ -137,6 +151,8 @@ function testCapture(aWindow) {
|
|||||||
|
|
||||||
executeSoon(function() {
|
executeSoon(function() {
|
||||||
ok(checkTemporaryFile(), "Screenshot got created");
|
ok(checkTemporaryFile(), "Screenshot got created");
|
||||||
|
captureTest--;
|
||||||
|
captureTestFinish();
|
||||||
});
|
});
|
||||||
|
|
||||||
DeveloperToolbarTestPW.exec(aWindow, {
|
DeveloperToolbarTestPW.exec(aWindow, {
|
||||||
@ -153,6 +169,7 @@ function testCapture(aWindow) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
ok(checkClipboard(), "Screenshot got created and copied");
|
ok(checkClipboard(), "Screenshot got created and copied");
|
||||||
|
captureTest--;
|
||||||
|
|
||||||
DeveloperToolbarTestPW.exec(aWindow, {
|
DeveloperToolbarTestPW.exec(aWindow, {
|
||||||
typed: "screenshot --clipboard",
|
typed: "screenshot --clipboard",
|
||||||
@ -168,4 +185,6 @@ function testCapture(aWindow) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
ok(checkClipboard(), "Screenshot present in clipboard");
|
ok(checkClipboard(), "Screenshot present in clipboard");
|
||||||
|
captureTest--;
|
||||||
|
captureTestFinish();
|
||||||
}
|
}
|
||||||
|
@ -393,7 +393,6 @@ DeveloperToolbarTestPW.test = function DTTPW_test(aWindow, uri, target, isGcli,
|
|||||||
if (appMenuItem) {
|
if (appMenuItem) {
|
||||||
appMenuItem.hidden = true;
|
appMenuItem.hidden = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// leakHunt({ DeveloperToolbar: DeveloperToolbar });
|
// leakHunt({ DeveloperToolbar: DeveloperToolbar });
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -408,13 +407,12 @@ DeveloperToolbarTestPW.test = function DTTPW_test(aWindow, uri, target, isGcli,
|
|||||||
appMenuItem.hidden = false;
|
appMenuItem.hidden = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
aWindow.gBrowser.selectedTab = aWindow.gBrowser.addTab();
|
let browser = aWindow.gBrowser.selectedBrowser;
|
||||||
aWindow.content.location = uri;
|
browser.addEventListener("load", function onTabLoad() {
|
||||||
|
if (aWindow.content.location.href != uri) {
|
||||||
let tab = aWindow.gBrowser.selectedTab;
|
browser.loadURI(uri);
|
||||||
let browser = aWindow.gBrowser.getBrowserForTab(tab);
|
return;
|
||||||
|
}
|
||||||
var onTabLoad = function() {
|
|
||||||
browser.removeEventListener("load", onTabLoad, true);
|
browser.removeEventListener("load", onTabLoad, true);
|
||||||
|
|
||||||
DeveloperToolbarTestPW.show(aWindow, function() {
|
DeveloperToolbarTestPW.show(aWindow, function() {
|
||||||
@ -430,35 +428,41 @@ DeveloperToolbarTestPW.test = function DTTPW_test(aWindow, uri, target, isGcli,
|
|||||||
|
|
||||||
if (Array.isArray(target)) {
|
if (Array.isArray(target)) {
|
||||||
try {
|
try {
|
||||||
target.forEach(function(func) {
|
var args = isGcli ? options : aWindow;
|
||||||
var args = isGcli ? [ options ] : [ aWindow ];
|
var targetCount = 0;
|
||||||
func.apply(null, args);
|
function callTarget() {
|
||||||
});
|
if (targetCount < target.length) {
|
||||||
cleanup();
|
info("Running target test: " + targetCount);
|
||||||
aCallback();
|
target[targetCount++](args, callTarget);
|
||||||
}
|
} else {
|
||||||
catch (ex) {
|
info("Clean up and continue test");
|
||||||
|
cleanup();
|
||||||
|
aCallback();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
callTarget();
|
||||||
|
} catch (ex) {
|
||||||
ok(false, "" + ex);
|
ok(false, "" + ex);
|
||||||
DeveloperToolbarTestPW._finish(aWindow);
|
DeveloperToolbarTestPW._finish(aWindow);
|
||||||
throw ex;
|
throw ex;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
try {
|
try {
|
||||||
target(aWindow);
|
target(aWindow, function() {
|
||||||
cleanup();
|
info("Clean up and continue test");
|
||||||
aCallback();
|
cleanup();
|
||||||
}
|
aCallback();
|
||||||
catch (ex) {
|
});
|
||||||
|
} catch (ex) {
|
||||||
ok(false, "" + ex);
|
ok(false, "" + ex);
|
||||||
DeveloperToolbarTestPW._finish(aWindow);
|
DeveloperToolbarTestPW._finish(aWindow);
|
||||||
throw ex;
|
throw ex;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}, true);
|
||||||
|
|
||||||
browser.addEventListener("load", onTabLoad, true);
|
browser.loadURI(uri);
|
||||||
};
|
};
|
||||||
|
|
||||||
DeveloperToolbarTestPW._outstanding = [];
|
DeveloperToolbarTestPW._outstanding = [];
|
||||||
|
Loading…
Reference in New Issue
Block a user