зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1235372, re-enable browser_contextmenu.js in e10s, r=florian
This commit is contained in:
Родитель
4e40f85263
Коммит
29c0814a0f
|
@ -23,7 +23,6 @@ skip-if = e10s # Bug ?????? - some issue with progress listeners [JavaScript Err
|
|||
[browser_bing_behavior.js]
|
||||
skip-if = e10s # Bug ?????? - some issue with progress listeners [JavaScript Error: "req.originalURI is null" {file: "chrome://mochitests/content/browser/browser/components/search/test/browser_bing_behavior.js" line: 127}]
|
||||
[browser_contextmenu.js]
|
||||
skip-if = e10s # Bug ?????? - Test touches content (content.window.getSelection().QueryInterface(Ci.nsISelectionPrivate)....)
|
||||
[browser_eBay.js]
|
||||
[browser_eBay_behavior.js]
|
||||
skip-if = e10s # Bug ?????? - some issue with progress listeners [JavaScript Error: "req.originalURI is null" {file: "chrome://mochitests/content/browser/browser/components/search/test/browser_bing_behavior.js" line: 127}]
|
||||
|
|
|
@ -4,9 +4,7 @@
|
|||
* Test searching for the selected text using the context menu
|
||||
*/
|
||||
|
||||
function test() {
|
||||
waitForExplicitFinish();
|
||||
|
||||
add_task(function* () {
|
||||
const ss = Services.search;
|
||||
const ENGINE_NAME = "Foo";
|
||||
var contextMenu;
|
||||
|
@ -22,90 +20,79 @@ function test() {
|
|||
resProt.setSubstitution("search-plugins",
|
||||
Services.io.newURI(url, null, null));
|
||||
|
||||
function observer(aSub, aTopic, aData) {
|
||||
switch (aData) {
|
||||
case "engine-added":
|
||||
var engine = ss.getEngineByName(ENGINE_NAME);
|
||||
ok(engine, "Engine was added.");
|
||||
ss.currentEngine = engine;
|
||||
envService.set("XPCSHELL_TEST_PROFILE_DIR", originalValue);
|
||||
resProt.setSubstitution("search-plugins", originalSubstitution);
|
||||
break;
|
||||
case "engine-current":
|
||||
is(ss.currentEngine.name, ENGINE_NAME, "currentEngine set");
|
||||
startTest();
|
||||
break;
|
||||
case "engine-removed":
|
||||
Services.obs.removeObserver(observer, "browser-search-engine-modified");
|
||||
finish();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Services.obs.addObserver(observer, "browser-search-engine-modified", false);
|
||||
ss.addEngine("resource://search-plugins/testEngine_mozsearch.xml",
|
||||
null, "data:image/x-icon,%00", false);
|
||||
|
||||
function startTest() {
|
||||
contextMenu = document.getElementById("contentAreaContextMenu");
|
||||
ok(contextMenu, "Got context menu XUL");
|
||||
|
||||
doOnloadOnce(testContextMenu);
|
||||
let tab = gBrowser.selectedTab = gBrowser.addTab("data:text/plain;charset=utf8,test%20search");
|
||||
registerCleanupFunction(function () {
|
||||
gBrowser.removeTab(tab);
|
||||
});
|
||||
}
|
||||
|
||||
function testContextMenu() {
|
||||
function rightClickOnDocument() {
|
||||
info("rightClickOnDocument: " + content.window.location);
|
||||
waitForBrowserContextMenu(checkContextMenu);
|
||||
var clickTarget = content.document.body;
|
||||
var eventDetails = { type: "contextmenu", button: 2 };
|
||||
EventUtils.synthesizeMouseAtCenter(clickTarget, eventDetails, content);
|
||||
}
|
||||
|
||||
// check the search menu item and then perform a search
|
||||
function checkContextMenu() {
|
||||
info("checkContextMenu");
|
||||
var searchItem = contextMenu.getElementsByAttribute("id", "context-searchselect")[0];
|
||||
ok(searchItem, "Got search context menu item");
|
||||
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");
|
||||
doOnloadOnce(checkSearchURL);
|
||||
searchItem.click();
|
||||
contextMenu.hidePopup();
|
||||
}
|
||||
|
||||
function checkSearchURL(event) {
|
||||
is(event.originalTarget.URL,
|
||||
"http://mochi.test:8888/browser/browser/components/search/test/?test=test+search&ie=utf-8&channel=contextsearch",
|
||||
"Checking context menu search URL");
|
||||
// Remove the tab opened by the search
|
||||
gBrowser.removeCurrentTab();
|
||||
ss.removeEngine(ss.currentEngine);
|
||||
}
|
||||
|
||||
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);
|
||||
let searchDonePromise;
|
||||
yield new Promise(resolve => {
|
||||
function observer(aSub, aTopic, aData) {
|
||||
switch (aData) {
|
||||
case "engine-added":
|
||||
var engine = ss.getEngineByName(ENGINE_NAME);
|
||||
ok(engine, "Engine was added.");
|
||||
ss.currentEngine = engine;
|
||||
envService.set("XPCSHELL_TEST_PROFILE_DIR", originalValue);
|
||||
resProt.setSubstitution("search-plugins", originalSubstitution);
|
||||
break;
|
||||
case "engine-current":
|
||||
is(ss.currentEngine.name, ENGINE_NAME, "currentEngine set");
|
||||
resolve();
|
||||
break;
|
||||
case "engine-removed":
|
||||
Services.obs.removeObserver(observer, "browser-search-engine-modified");
|
||||
if (searchDonePromise) {
|
||||
searchDonePromise();
|
||||
}
|
||||
break;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// Delay the select all to avoid intermittent selection failures.
|
||||
setTimeout(function delaySelectAll() {
|
||||
info("delaySelectAll: " + content.window.location.toString());
|
||||
// add a listener to know when the selection takes effect
|
||||
content.window.getSelection().QueryInterface(Ci.nsISelectionPrivate).
|
||||
addSelectionListener(selectionListener);
|
||||
// select the text on the page
|
||||
goDoCommand('cmd_selectAll');
|
||||
}, 500);
|
||||
}
|
||||
}
|
||||
Services.obs.addObserver(observer, "browser-search-engine-modified", false);
|
||||
ss.addEngine("resource://search-plugins/testEngine_mozsearch.xml",
|
||||
null, "data:image/x-icon,%00", false);
|
||||
});
|
||||
|
||||
contextMenu = document.getElementById("contentAreaContextMenu");
|
||||
ok(contextMenu, "Got context menu XUL");
|
||||
|
||||
let tab = yield BrowserTestUtils.openNewForegroundTab(gBrowser, "data:text/plain;charset=utf8,test%20search");
|
||||
|
||||
yield ContentTask.spawn(tab.linkedBrowser, "", function*() {
|
||||
return new Promise(resolve => {
|
||||
content.document.addEventListener("selectionchange", function selectionChanged() {
|
||||
content.document.removeEventListener("selectionchange", selectionChanged);
|
||||
resolve();
|
||||
});
|
||||
content.document.getSelection().selectAllChildren(content.document.body);
|
||||
});
|
||||
});
|
||||
|
||||
var eventDetails = { type: "contextmenu", button: 2 };
|
||||
|
||||
let popupPromise = BrowserTestUtils.waitForEvent(contextMenu, "popupshown");
|
||||
BrowserTestUtils.synthesizeMouseAtCenter("body", eventDetails, gBrowser.selectedBrowser);
|
||||
yield popupPromise;
|
||||
|
||||
info("checkContextMenu");
|
||||
var searchItem = contextMenu.getElementsByAttribute("id", "context-searchselect")[0];
|
||||
ok(searchItem, "Got search context menu item");
|
||||
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");
|
||||
|
||||
yield BrowserTestUtils.openNewForegroundTab(gBrowser, () => {
|
||||
searchItem.click();
|
||||
});
|
||||
|
||||
is(gBrowser.currentURI.spec,
|
||||
"http://mochi.test:8888/browser/browser/components/search/test/?test=test+search&ie=utf-8&channel=contextsearch",
|
||||
"Checking context menu search URL");
|
||||
|
||||
contextMenu.hidePopup();
|
||||
|
||||
// Remove the tab opened by the search
|
||||
gBrowser.removeCurrentTab();
|
||||
|
||||
yield new Promise(resolve => {
|
||||
searchDonePromise = resolve;
|
||||
ss.removeEngine(ss.currentEngine);
|
||||
});
|
||||
|
||||
gBrowser.removeCurrentTab();
|
||||
});
|
||||
|
|
|
@ -42,21 +42,6 @@ function getLocalizedPref(aPrefName, aDefault) {
|
|||
return aDefault;
|
||||
}
|
||||
|
||||
function waitForPopupShown(aPopupId, aCallback) {
|
||||
let popup = document.getElementById(aPopupId);
|
||||
info("waitForPopupShown: got popup: " + popup.id);
|
||||
function onPopupShown() {
|
||||
info("onPopupShown");
|
||||
removePopupShownListener();
|
||||
SimpleTest.executeSoon(aCallback);
|
||||
}
|
||||
function removePopupShownListener() {
|
||||
popup.removeEventListener("popupshown", onPopupShown);
|
||||
}
|
||||
popup.addEventListener("popupshown", onPopupShown);
|
||||
registerCleanupFunction(removePopupShownListener);
|
||||
}
|
||||
|
||||
function promiseEvent(aTarget, aEventName, aPreventDefault) {
|
||||
let deferred = Promise.defer();
|
||||
aTarget.addEventListener(aEventName, function onEvent(aEvent) {
|
||||
|
@ -69,25 +54,6 @@ function promiseEvent(aTarget, aEventName, aPreventDefault) {
|
|||
return deferred.promise;
|
||||
}
|
||||
|
||||
function waitForBrowserContextMenu(aCallback) {
|
||||
waitForPopupShown(gBrowser.selectedBrowser.contextMenu, aCallback);
|
||||
}
|
||||
|
||||
function doOnloadOnce(aCallback) {
|
||||
function doOnloadOnceListener(aEvent) {
|
||||
info("doOnloadOnce: " + aEvent.originalTarget.location);
|
||||
removeDoOnloadOnceListener();
|
||||
SimpleTest.executeSoon(function doOnloadOnceCallback() {
|
||||
aCallback(aEvent);
|
||||
});
|
||||
}
|
||||
function removeDoOnloadOnceListener() {
|
||||
gBrowser.removeEventListener("load", doOnloadOnceListener, true);
|
||||
}
|
||||
gBrowser.addEventListener("load", doOnloadOnceListener, true);
|
||||
registerCleanupFunction(removeDoOnloadOnceListener);
|
||||
}
|
||||
|
||||
function promiseNewEngine(basename, options = {}) {
|
||||
return new Promise((resolve, reject) => {
|
||||
//Default the setAsCurrent option to true.
|
||||
|
|
Загрузка…
Ссылка в новой задаче