зеркало из https://github.com/mozilla/gecko-dev.git
Bug 850349 - Cleanup browser search tests while debugging intermittent failure in browser_contextmenu.js. r=gavin
* browser_426329.js - Fix exception in popupshowing event listener causing search history dropdown to remain open on subsequent tests. * browser_contextmenu.js - Add some debug messages. - Move |doOnloadOnce(checkSearchURL);| just before the search tab opens so there is less interference with later tests. - Add nsISelectionListener to know when selection has finished. * head.js - Consolidate duplicated doOnloadOnce function. * test.html - Fix character set warning.
This commit is contained in:
Родитель
f86723d135
Коммит
9a64baf98f
|
@ -201,11 +201,11 @@ function test() {
|
||||||
|
|
||||||
function testAutocomplete() {
|
function testAutocomplete() {
|
||||||
var popup = searchBar.textbox.popup;
|
var popup = searchBar.textbox.popup;
|
||||||
popup.addEventListener("popupshowing", function() {
|
popup.addEventListener("popupshowing", function testACPopupShowing() {
|
||||||
|
popup.removeEventListener("popupshowing", testACPopupShowing);
|
||||||
checkMenuEntries(searchEntries);
|
checkMenuEntries(searchEntries);
|
||||||
finalize();
|
SimpleTest.executeSoon(finalize);
|
||||||
popup.removeEventListener("popupshowing", this, false);
|
});
|
||||||
}, false);
|
|
||||||
searchBar.textbox.showHistoryPopup();
|
searchBar.textbox.showHistoryPopup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -219,13 +219,6 @@ function test() {
|
||||||
ss.removeEngine(engine);
|
ss.removeEngine(engine);
|
||||||
}
|
}
|
||||||
|
|
||||||
function doOnloadOnce(callback) {
|
|
||||||
gBrowser.addEventListener("DOMContentLoaded", function(event) {
|
|
||||||
gBrowser.removeEventListener("DOMContentLoaded", arguments.callee, true);
|
|
||||||
callback(event);
|
|
||||||
}, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
function simulateClick(aEvent, aTarget) {
|
function simulateClick(aEvent, aTarget) {
|
||||||
var event = document.createEvent("MouseEvent");
|
var event = document.createEvent("MouseEvent");
|
||||||
var ctrlKeyArg = aEvent.ctrlKey || false;
|
var ctrlKeyArg = aEvent.ctrlKey || false;
|
||||||
|
@ -236,7 +229,7 @@ function test() {
|
||||||
event.initMouseEvent("click", true, true, window,
|
event.initMouseEvent("click", true, true, window,
|
||||||
0, 0, 0, 0, 0,
|
0, 0, 0, 0, 0,
|
||||||
ctrlKeyArg, altKeyArg, shiftKeyArg, metaKeyArg,
|
ctrlKeyArg, altKeyArg, shiftKeyArg, metaKeyArg,
|
||||||
buttonArg, null);
|
buttonArg, null);
|
||||||
aTarget.dispatchEvent(event);
|
aTarget.dispatchEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -252,7 +245,7 @@ function test() {
|
||||||
var actualValues = getMenuEntries();
|
var actualValues = getMenuEntries();
|
||||||
is(actualValues.length, expectedValues.length, "Checking length of expected menu");
|
is(actualValues.length, expectedValues.length, "Checking length of expected menu");
|
||||||
for (var i = 0; i < expectedValues.length; i++)
|
for (var i = 0; i < expectedValues.length; i++)
|
||||||
is(actualValues[i], expectedValues[i], "Checking menu entry #"+i);
|
is(actualValues[i], expectedValues[i], "Checking menu entry #" + i);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getMenuEntries() {
|
function getMenuEntries() {
|
||||||
|
|
|
@ -30,6 +30,7 @@ function test() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
registerCleanupFunction(finalize);
|
||||||
Services.obs.addObserver(observer, "browser-search-engine-modified", false);
|
Services.obs.addObserver(observer, "browser-search-engine-modified", false);
|
||||||
ss.addEngine("http://mochi.test:8888/browser/browser/components/search/test/testEngine_mozsearch.xml",
|
ss.addEngine("http://mochi.test:8888/browser/browser/components/search/test/testEngine_mozsearch.xml",
|
||||||
Ci.nsISearchEngine.DATA_XML, "data:image/x-icon,%00",
|
Ci.nsISearchEngine.DATA_XML, "data:image/x-icon,%00",
|
||||||
|
@ -46,6 +47,7 @@ function test() {
|
||||||
|
|
||||||
function testContextMenu() {
|
function testContextMenu() {
|
||||||
function rightClickOnDocument() {
|
function rightClickOnDocument() {
|
||||||
|
info("rightClickOnDocument: " + content.window.location);
|
||||||
waitForBrowserContextMenu(checkContextMenu);
|
waitForBrowserContextMenu(checkContextMenu);
|
||||||
var clickTarget = content.document.body;
|
var clickTarget = content.document.body;
|
||||||
var eventDetails = { type: "contextmenu", button: 2 };
|
var eventDetails = { type: "contextmenu", button: 2 };
|
||||||
|
@ -54,30 +56,39 @@ function test() {
|
||||||
|
|
||||||
// check the search menu item and then perform a search
|
// check the search menu item and then perform a search
|
||||||
function checkContextMenu() {
|
function checkContextMenu() {
|
||||||
|
info("checkContextMenu");
|
||||||
var searchItem = contextMenu.getElementsByAttribute("id", "context-searchselect")[0];
|
var searchItem = contextMenu.getElementsByAttribute("id", "context-searchselect")[0];
|
||||||
ok(searchItem, "Got search context menu item");
|
ok(searchItem, "Got search context menu item");
|
||||||
is(searchItem.label, 'Search ' + ENGINE_NAME + ' for "test search"', "Check context menu label");
|
is(searchItem.label, 'Search ' + ENGINE_NAME + ' for "test search"', "Check context menu label");
|
||||||
is(searchItem.disabled, false, "Check that search context menu item is enabled");
|
is(searchItem.disabled, false, "Check that search context menu item is enabled");
|
||||||
|
doOnloadOnce(checkSearchURL);
|
||||||
searchItem.click();
|
searchItem.click();
|
||||||
contextMenu.hidePopup();
|
contextMenu.hidePopup();
|
||||||
}
|
}
|
||||||
|
|
||||||
function checkSearchURL(event){
|
function checkSearchURL(event) {
|
||||||
is(event.originalTarget.URL,
|
is(event.originalTarget.URL,
|
||||||
"http://mochi.test:8888/browser/browser/components/search/test/?test=test+search&ie=utf-8&client=app&channel=contextsearch",
|
"http://mochi.test:8888/browser/browser/components/search/test/?test=test+search&ie=utf-8&client=app&channel=contextsearch",
|
||||||
"Checking context menu search URL");
|
"Checking context menu search URL");
|
||||||
finalize();
|
finalize();
|
||||||
}
|
}
|
||||||
|
|
||||||
doOnloadOnce(checkSearchURL);
|
var selectionListener = {
|
||||||
|
notifySelectionChanged: function(doc, sel, reason) {
|
||||||
|
if (reason != Ci.nsISelectionListener.SELECTALL_REASON || sel.toString() != "test search")
|
||||||
|
return;
|
||||||
|
info("notifySelectionChanged: Text selected");
|
||||||
|
content.window.getSelection().QueryInterface(Ci.nsISelectionPrivate).
|
||||||
|
removeSelectionListener(selectionListener);
|
||||||
|
SimpleTest.executeSoon(rightClickOnDocument);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// add a listener to know when the selection takes effect
|
||||||
|
content.window.getSelection().QueryInterface(Ci.nsISelectionPrivate).
|
||||||
|
addSelectionListener(selectionListener);
|
||||||
// select the text on the page
|
// select the text on the page
|
||||||
var selectAllItem = contextMenu.getElementsByAttribute("id", "context-selectall")[0];
|
goDoCommand('cmd_selectAll');
|
||||||
ok(selectAllItem, "Got select all context menu item");
|
|
||||||
selectAllItem.click();
|
|
||||||
|
|
||||||
// wait for the selection to take effect
|
|
||||||
SimpleTest.executeSoon(rightClickOnDocument);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function finalize() {
|
function finalize() {
|
||||||
|
@ -86,13 +97,7 @@ function test() {
|
||||||
}
|
}
|
||||||
content.location.href = "about:blank";
|
content.location.href = "about:blank";
|
||||||
var engine = ss.getEngineByName(ENGINE_NAME);
|
var engine = ss.getEngineByName(ENGINE_NAME);
|
||||||
ss.removeEngine(engine);
|
if (engine)
|
||||||
}
|
ss.removeEngine(engine);
|
||||||
|
|
||||||
function doOnloadOnce(callback) {
|
|
||||||
gBrowser.addEventListener("DOMContentLoaded", function handleLoad(event) {
|
|
||||||
gBrowser.removeEventListener("DOMContentLoaded", handleLoad, true);
|
|
||||||
callback(event);
|
|
||||||
}, true);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,13 +20,32 @@ function isSubObjectOf(expectedObj, actualObj, name) {
|
||||||
|
|
||||||
function waitForPopupShown(aPopupId, aCallback) {
|
function waitForPopupShown(aPopupId, aCallback) {
|
||||||
let popup = document.getElementById(aPopupId);
|
let popup = document.getElementById(aPopupId);
|
||||||
|
info("waitForPopupShown: got popup: " + popup.id);
|
||||||
function onPopupShown() {
|
function onPopupShown() {
|
||||||
popup.removeEventListener("popupshown", onPopupShown);
|
info("onPopupShown");
|
||||||
|
removePopupShownListener();
|
||||||
SimpleTest.executeSoon(aCallback);
|
SimpleTest.executeSoon(aCallback);
|
||||||
}
|
}
|
||||||
|
function removePopupShownListener() {
|
||||||
|
popup.removeEventListener("popupshown", onPopupShown);
|
||||||
|
}
|
||||||
popup.addEventListener("popupshown", onPopupShown);
|
popup.addEventListener("popupshown", onPopupShown);
|
||||||
|
registerCleanupFunction(removePopupShownListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
function waitForBrowserContextMenu(aCallback) {
|
function waitForBrowserContextMenu(aCallback) {
|
||||||
waitForPopupShown(gBrowser.selectedBrowser.contextMenu, aCallback);
|
waitForPopupShown(gBrowser.selectedBrowser.contextMenu, aCallback);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function doOnloadOnce(aCallback) {
|
||||||
|
function doOnloadOnceListener(aEvent) {
|
||||||
|
info("doOnloadOnce: " + aEvent.originalTarget.location);
|
||||||
|
removeDoOnloadOnceListener();
|
||||||
|
aCallback(aEvent);
|
||||||
|
}
|
||||||
|
function removeDoOnloadOnceListener() {
|
||||||
|
gBrowser.removeEventListener("DOMContentLoaded", doOnloadOnceListener);
|
||||||
|
}
|
||||||
|
gBrowser.addEventListener("DOMContentLoaded", doOnloadOnceListener);
|
||||||
|
registerCleanupFunction(removeDoOnloadOnceListener);
|
||||||
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
|
<meta charset="utf-8" />
|
||||||
<title>Bug 426329</title>
|
<title>Bug 426329</title>
|
||||||
</head>
|
</head>
|
||||||
<body></body>
|
<body></body>
|
||||||
|
|
Загрузка…
Ссылка в новой задаче