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() {
|
||||
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) {
|
||||
let win = OpenBrowserWindow({private: aPrivate});
|
||||
win.addEventListener("load", function onLoad() {
|
||||
@ -20,29 +29,25 @@ function test() {
|
||||
};
|
||||
|
||||
testOnWindow(false, function(win) {
|
||||
info("Testing on public window");
|
||||
windowsToClose.push(win);
|
||||
DeveloperToolbarTestPW.test(win, TEST_URI, [ testInput, testCapture ], null, function() {
|
||||
win.close();
|
||||
testOnWindow(true, function(win) {
|
||||
executeSoon(function() {
|
||||
DeveloperToolbarTestPW.test(win, TEST_URI, [ testInput, testCapture ], null, function() {
|
||||
win.close();
|
||||
finish();
|
||||
});
|
||||
})
|
||||
info("Testing on private window");
|
||||
windowsToClose.push(win);
|
||||
DeveloperToolbarTestPW.test(win, TEST_URI, [ testInput, testCapture ], null, finish);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
function testInput(aWindow) {
|
||||
function testInput(aWindow, aCallback) {
|
||||
helpers_perwindowpb.setInput('screenshot');
|
||||
helpers_perwindowpb.check({
|
||||
input: 'screenshot',
|
||||
markup: 'VVVVVVVVVV',
|
||||
status: 'VALID',
|
||||
args: {
|
||||
}
|
||||
args: { }
|
||||
});
|
||||
|
||||
helpers_perwindowpb.setInput('screenshot abc.png');
|
||||
@ -85,9 +90,11 @@ function testInput(aWindow) {
|
||||
selector: { value: aWindow.content.document.getElementById("testImage")},
|
||||
}
|
||||
});
|
||||
|
||||
aCallback();
|
||||
}
|
||||
|
||||
function testCapture(aWindow) {
|
||||
function testCapture(aWindow, aCallback) {
|
||||
function checkTemporaryFile() {
|
||||
// Create a temporary file.
|
||||
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() {
|
||||
try {
|
||||
let clipid = Ci.nsIClipboard;
|
||||
@ -137,6 +151,8 @@ function testCapture(aWindow) {
|
||||
|
||||
executeSoon(function() {
|
||||
ok(checkTemporaryFile(), "Screenshot got created");
|
||||
captureTest--;
|
||||
captureTestFinish();
|
||||
});
|
||||
|
||||
DeveloperToolbarTestPW.exec(aWindow, {
|
||||
@ -153,6 +169,7 @@ function testCapture(aWindow) {
|
||||
});
|
||||
|
||||
ok(checkClipboard(), "Screenshot got created and copied");
|
||||
captureTest--;
|
||||
|
||||
DeveloperToolbarTestPW.exec(aWindow, {
|
||||
typed: "screenshot --clipboard",
|
||||
@ -168,4 +185,6 @@ function testCapture(aWindow) {
|
||||
});
|
||||
|
||||
ok(checkClipboard(), "Screenshot present in clipboard");
|
||||
captureTest--;
|
||||
captureTestFinish();
|
||||
}
|
||||
|
@ -393,7 +393,6 @@ DeveloperToolbarTestPW.test = function DTTPW_test(aWindow, uri, target, isGcli,
|
||||
if (appMenuItem) {
|
||||
appMenuItem.hidden = true;
|
||||
}
|
||||
|
||||
// leakHunt({ DeveloperToolbar: DeveloperToolbar });
|
||||
};
|
||||
|
||||
@ -408,13 +407,12 @@ DeveloperToolbarTestPW.test = function DTTPW_test(aWindow, uri, target, isGcli,
|
||||
appMenuItem.hidden = false;
|
||||
}
|
||||
|
||||
aWindow.gBrowser.selectedTab = aWindow.gBrowser.addTab();
|
||||
aWindow.content.location = uri;
|
||||
|
||||
let tab = aWindow.gBrowser.selectedTab;
|
||||
let browser = aWindow.gBrowser.getBrowserForTab(tab);
|
||||
|
||||
var onTabLoad = function() {
|
||||
let browser = aWindow.gBrowser.selectedBrowser;
|
||||
browser.addEventListener("load", function onTabLoad() {
|
||||
if (aWindow.content.location.href != uri) {
|
||||
browser.loadURI(uri);
|
||||
return;
|
||||
}
|
||||
browser.removeEventListener("load", onTabLoad, true);
|
||||
|
||||
DeveloperToolbarTestPW.show(aWindow, function() {
|
||||
@ -430,35 +428,41 @@ DeveloperToolbarTestPW.test = function DTTPW_test(aWindow, uri, target, isGcli,
|
||||
|
||||
if (Array.isArray(target)) {
|
||||
try {
|
||||
target.forEach(function(func) {
|
||||
var args = isGcli ? [ options ] : [ aWindow ];
|
||||
func.apply(null, args);
|
||||
});
|
||||
cleanup();
|
||||
aCallback();
|
||||
}
|
||||
catch (ex) {
|
||||
var args = isGcli ? options : aWindow;
|
||||
var targetCount = 0;
|
||||
function callTarget() {
|
||||
if (targetCount < target.length) {
|
||||
info("Running target test: " + targetCount);
|
||||
target[targetCount++](args, callTarget);
|
||||
} else {
|
||||
info("Clean up and continue test");
|
||||
cleanup();
|
||||
aCallback();
|
||||
}
|
||||
}
|
||||
callTarget();
|
||||
} catch (ex) {
|
||||
ok(false, "" + ex);
|
||||
DeveloperToolbarTestPW._finish(aWindow);
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
try {
|
||||
target(aWindow);
|
||||
cleanup();
|
||||
aCallback();
|
||||
}
|
||||
catch (ex) {
|
||||
target(aWindow, function() {
|
||||
info("Clean up and continue test");
|
||||
cleanup();
|
||||
aCallback();
|
||||
});
|
||||
} catch (ex) {
|
||||
ok(false, "" + ex);
|
||||
DeveloperToolbarTestPW._finish(aWindow);
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}, true);
|
||||
|
||||
browser.addEventListener("load", onTabLoad, true);
|
||||
browser.loadURI(uri);
|
||||
};
|
||||
|
||||
DeveloperToolbarTestPW._outstanding = [];
|
||||
|
Loading…
Reference in New Issue
Block a user