зеркало из https://github.com/mozilla/gecko-dev.git
Back out 3d8fc342348b (bug 469434) for browser_contextmenu.js timeouts
This commit is contained in:
Родитель
c646f211b4
Коммит
06fa50e27e
|
@ -111,19 +111,10 @@
|
|||
<key id="key_textZoomReset2" key="&textReset.commandkey2;" command="cmd_textZoomReset" modifiers="accel"/>
|
||||
</keyset>
|
||||
|
||||
<menupopup id="viewSourceContextMenu"
|
||||
onpopupshowing="contextMenuShowing();">
|
||||
<menupopup id="viewSourceContextMenu">
|
||||
<menuitem id="cMenu_findAgain"/>
|
||||
<menuseparator/>
|
||||
<menuitem id="cMenu_copy"/>
|
||||
<menuitem id="context-copyLink"
|
||||
label="©LinkCmd.label;"
|
||||
accesskey="©LinkCmd.accesskey;"
|
||||
oncommand="contextMenuCopyLinkOrEmail();"/>
|
||||
<menuitem id="context-copyEmail"
|
||||
label="©EmailCmd.label;"
|
||||
accesskey="©EmailCmd.accesskey;"
|
||||
oncommand="contextMenuCopyLinkOrEmail();"/>
|
||||
<menuseparator/>
|
||||
<menuitem id="cMenu_selectAll"/>
|
||||
</menupopup>
|
||||
|
|
|
@ -47,8 +47,7 @@ var gGoToLine = 0;
|
|||
|
||||
[
|
||||
["gBrowser", "content"],
|
||||
["gViewSourceBundle", "viewSourceBundle"],
|
||||
["gContextMenu", "viewSourceContextMenu"]
|
||||
["gViewSourceBundle", "viewSourceBundle"]
|
||||
].forEach(function ([name, id]) {
|
||||
window.__defineGetter__(name, function () {
|
||||
var element = document.getElementById(id);
|
||||
|
@ -798,25 +797,3 @@ function FillInHTMLTooltip(tipElement)
|
|||
return retVal;
|
||||
}
|
||||
|
||||
function contextMenuShowing() {
|
||||
var isLink = false;
|
||||
var isEmail = false;
|
||||
if (gContextMenu.triggerNode && gContextMenu.triggerNode.localName == 'a') {
|
||||
if (gContextMenu.triggerNode.href.indexOf('view-source:') == 0)
|
||||
isLink = true;
|
||||
if (gContextMenu.triggerNode.href.indexOf('mailto:') == 0)
|
||||
isEmail = true;
|
||||
}
|
||||
document.getElementById('context-copyLink').hidden = !isLink;
|
||||
document.getElementById('context-copyEmail').hidden = !isEmail;
|
||||
}
|
||||
|
||||
function contextMenuCopyLinkOrEmail() {
|
||||
if (!gContextMenu.triggerNode)
|
||||
return;
|
||||
|
||||
var href = gContextMenu.triggerNode.href;
|
||||
var clipboard = Cc['@mozilla.org/widget/clipboardhelper;1'].
|
||||
getService(Ci.nsIClipboardHelper);
|
||||
clipboard.copyString(href.substring(href.indexOf(':') + 1));
|
||||
}
|
||||
|
|
|
@ -144,8 +144,7 @@
|
|||
|
||||
<tooltip id="aHTMLTooltip" onpopupshowing="return FillInHTMLTooltip(document.tooltipNode);"/>
|
||||
|
||||
<menupopup id="viewSourceContextMenu"
|
||||
onpopupshowing="contextMenuShowing();">
|
||||
<menupopup id="viewSourceContextMenu">
|
||||
<menuitem id="context-back"
|
||||
label="&backCmd.label;"
|
||||
accesskey="&backCmd.accesskey;"
|
||||
|
@ -160,14 +159,6 @@
|
|||
<menuitem id="cMenu_findAgain"/>
|
||||
<menuseparator/>
|
||||
<menuitem id="cMenu_copy"/>
|
||||
<menuitem id="context-copyLink"
|
||||
label="©LinkCmd.label;"
|
||||
accesskey="©LinkCmd.accesskey;"
|
||||
oncommand="contextMenuCopyLinkOrEmail();"/>
|
||||
<menuitem id="context-copyEmail"
|
||||
label="©EmailCmd.label;"
|
||||
accesskey="©EmailCmd.accesskey;"
|
||||
oncommand="contextMenuCopyLinkOrEmail();"/>
|
||||
<menuseparator/>
|
||||
<menuitem id="cMenu_selectAll"/>
|
||||
</menupopup>
|
||||
|
|
|
@ -47,7 +47,6 @@ include $(topsrcdir)/config/rules.mk
|
|||
_BROWSER_CHROME_FILES = \
|
||||
browser_bug699356.js \
|
||||
browser_bug713810.js \
|
||||
browser_contextmenu.js \
|
||||
browser_viewsourceprefs.js \
|
||||
browser_viewsourceprefs_nonhtml.js \
|
||||
head.js \
|
||||
|
|
|
@ -1,85 +0,0 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/
|
||||
*/
|
||||
|
||||
let source = "data:text/html,text<link%20href='http://example.com/'%20/>more%20text<a%20href='mailto:abc@def.ghi'>email</a>";
|
||||
let gViewSourceWindow, gContextMenu, gCopyLinkMenuItem, gCopyEmailMenuItem;
|
||||
|
||||
let expectedData = [];
|
||||
let currentTest = 0;
|
||||
let partialTestRunning = false;
|
||||
|
||||
function test() {
|
||||
waitForExplicitFinish();
|
||||
openViewSourceWindow(source, onViewSourceWindowOpen);
|
||||
}
|
||||
|
||||
function onViewSourceWindowOpen(aWindow) {
|
||||
gViewSourceWindow = aWindow;
|
||||
|
||||
gContextMenu = aWindow.document.getElementById("viewSourceContextMenu");
|
||||
gCopyLinkMenuItem = aWindow.document.getElementById("context-copyLink");
|
||||
gCopyEmailMenuItem = aWindow.document.getElementById("context-copyEmail");
|
||||
|
||||
let aTags = aWindow.gBrowser.contentDocument.querySelectorAll("a[href]");
|
||||
is(aTags[0].href, "view-source:http://example.com/", "Link has correct href");
|
||||
is(aTags[1].href, "mailto:abc@def.ghi", "Link has correct href");
|
||||
let spanTag = aWindow.gBrowser.contentDocument.querySelector("span");
|
||||
|
||||
expectedData.push([aTags[0], true, false, "http://example.com/"]);
|
||||
expectedData.push([aTags[1], false, true, "abc@def.ghi"]);
|
||||
expectedData.push([spanTag, false, false, null]);
|
||||
|
||||
waitForFocus(runNextTest, aWindow);
|
||||
}
|
||||
|
||||
function runNextTest() {
|
||||
if (currentTest == expectedData.length) {
|
||||
closeViewSourceWindow(gViewSourceWindow, function() {
|
||||
if (partialTestRunning) {
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
partialTestRunning = true;
|
||||
currentTest = 0;
|
||||
expectedData = [];
|
||||
waitForFocus(function() {
|
||||
openDocumentSelect(source, "body", onViewSourceWindowOpen);
|
||||
}, window);
|
||||
});
|
||||
return;
|
||||
}
|
||||
let test = expectedData[currentTest++];
|
||||
checkMenuItems(test[0], test[1], test[2], test[3]);
|
||||
}
|
||||
|
||||
function checkMenuItems(popupNode, copyLinkExpected, copyEmailExpected, expectedClipboardContent) {
|
||||
popupNode.scrollIntoView();
|
||||
|
||||
let cachedEvent = null;
|
||||
let mouseFn = function(event) {
|
||||
cachedEvent = event;
|
||||
};
|
||||
|
||||
gViewSourceWindow.gBrowser.contentWindow.addEventListener("mousedown", mouseFn, false);
|
||||
EventUtils.synthesizeMouseAtCenter(popupNode, { button: 2 }, gViewSourceWindow.gBrowser.contentWindow);
|
||||
gViewSourceWindow.gBrowser.contentWindow.removeEventListener("mousedown", mouseFn, false);
|
||||
|
||||
gContextMenu.openPopup(popupNode, "after_start", 0, 0, false, false, cachedEvent);
|
||||
|
||||
is(gCopyLinkMenuItem.hidden, !copyLinkExpected, "Copy link menuitem is " + (copyLinkExpected ? "not hidden" : "hidden"));
|
||||
is(gCopyEmailMenuItem.hidden, !copyEmailExpected, "Copy email menuitem is " + (copyEmailExpected ? "not hidden" : "hidden"));
|
||||
|
||||
if (!copyLinkExpected && !copyEmailExpected) {
|
||||
runNextTest();
|
||||
return;
|
||||
}
|
||||
|
||||
waitForClipboard(expectedClipboardContent, function() {
|
||||
if (copyLinkExpected)
|
||||
gCopyLinkMenuItem.doCommand();
|
||||
else
|
||||
gCopyEmailMenuItem.doCommand();
|
||||
gContextMenu.hidePopup();
|
||||
}, runNextTest, runNextTest);
|
||||
}
|
|
@ -45,14 +45,14 @@ registerCleanupFunction(function() {
|
|||
});
|
||||
|
||||
function openDocument(aURI, aCallback) {
|
||||
let tab = gBrowser.addTab(aURI);
|
||||
let tab = window.gBrowser.addTab(aURI);
|
||||
let browser = tab.linkedBrowser;
|
||||
browser.addEventListener("DOMContentLoaded", function pageLoadedListener() {
|
||||
browser.removeEventListener("DOMContentLoaded", pageLoadedListener, false);
|
||||
aCallback(tab);
|
||||
}, false);
|
||||
registerCleanupFunction(function() {
|
||||
gBrowser.removeTab(tab);
|
||||
window.gBrowser.removeTab(tab);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -74,8 +74,3 @@ you can use these alternative items. Otherwise, their values should be empty. -
|
|||
<!ENTITY forwardCmd.accesskey "F">
|
||||
<!ENTITY goBackCmd.commandKey "[">
|
||||
<!ENTITY goForwardCmd.commandKey "]">
|
||||
|
||||
<!ENTITY copyLinkCmd.label "Copy Link Location">
|
||||
<!ENTITY copyLinkCmd.accesskey "L">
|
||||
<!ENTITY copyEmailCmd.label "Copy Email Address">
|
||||
<!ENTITY copyEmailCmd.accesskey "E">
|
||||
|
|
Загрузка…
Ссылка в новой задаче