зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1170011 - Disable infinite recursion on the View Source command; r=jaws
This disables the View Source command on view-source documents in the view-source-in-tab mode.
This commit is contained in:
Родитель
ea5bf98ce1
Коммит
48639c61a8
|
@ -382,7 +382,7 @@
|
|||
label="&viewPageSourceCmd.label;"
|
||||
accesskey="&viewPageSourceCmd.accesskey;"
|
||||
oncommand="BrowserViewSource(gContextMenu.browser);"
|
||||
observes="isImage"/>
|
||||
observes="canViewSource"/>
|
||||
<menuitem id="context-viewinfo"
|
||||
label="&viewPageInfoCmd.label;"
|
||||
accesskey="&viewPageInfoCmd.accesskey;"
|
||||
|
|
|
@ -39,7 +39,7 @@
|
|||
|
||||
<commandset id="editMenuCommands"/>
|
||||
|
||||
<command id="View:PageSource" oncommand="BrowserViewSource(window.gBrowser.selectedBrowser);" observes="isImage"/>
|
||||
<command id="View:PageSource" oncommand="BrowserViewSource(window.gBrowser.selectedBrowser);" observes="canViewSource"/>
|
||||
<command id="View:PageInfo" oncommand="BrowserPageInfo();"/>
|
||||
<command id="View:FullScreen" oncommand="BrowserFullScreen();"/>
|
||||
<command id="View:ReaderView" oncommand="ReaderParent.toggleReaderMode(event);"/>
|
||||
|
@ -174,6 +174,7 @@
|
|||
oncommand="gPopupBlockerObserver.dontShowMessage();"/>
|
||||
<broadcaster id="blockedPopupsSeparator"/>
|
||||
<broadcaster id="isImage"/>
|
||||
<broadcaster id="canViewSource"/>
|
||||
<broadcaster id="isFrameImage"/>
|
||||
<broadcaster id="singleFeedMenuitemState" disabled="true"/>
|
||||
<broadcaster id="multipleFeedsMenuState" hidden="true"/>
|
||||
|
@ -231,7 +232,9 @@
|
|||
<broadcaster id="devtoolsMenuBroadcaster_PageSource"
|
||||
label="&pageSourceCmd.label;"
|
||||
key="key_viewSource"
|
||||
command="View:PageSource"/>
|
||||
command="View:PageSource">
|
||||
<observes element="canViewSource" attribute="disabled"/>
|
||||
</broadcaster>
|
||||
<broadcaster id="devtoolsMenuBroadcaster_ErrorConsole"
|
||||
label="&errorConsoleCmd.label;"
|
||||
command="Tools:ErrorConsole"/>
|
||||
|
|
|
@ -4049,6 +4049,10 @@ var XULBrowserWindow = {
|
|||
delete this.isImage;
|
||||
return this.isImage = document.getElementById("isImage");
|
||||
},
|
||||
get canViewSource () {
|
||||
delete this.canViewSource;
|
||||
return this.canViewSource = document.getElementById("canViewSource");
|
||||
},
|
||||
|
||||
init: function () {
|
||||
// Initialize the security button's state and tooltip text.
|
||||
|
@ -4206,6 +4210,7 @@ var XULBrowserWindow = {
|
|||
if (aRequest) {
|
||||
let msg = "";
|
||||
let location;
|
||||
let canViewSource = true;
|
||||
// Get the URI either from a channel or a pseudo-object
|
||||
if (aRequest instanceof nsIChannel || "URI" in aRequest) {
|
||||
location = aRequest.URI;
|
||||
|
@ -4214,6 +4219,9 @@ var XULBrowserWindow = {
|
|||
if (location.scheme == "keyword" && aWebProgress.isTopLevel)
|
||||
gBrowser.userTypedValue = null;
|
||||
|
||||
canViewSource = !Services.prefs.getBoolPref("view_source.tab") ||
|
||||
location.scheme != "view-source";
|
||||
|
||||
if (location.spec != "about:blank") {
|
||||
switch (aStatus) {
|
||||
case Components.results.NS_ERROR_NET_TIMEOUT:
|
||||
|
@ -4227,10 +4235,18 @@ var XULBrowserWindow = {
|
|||
this.setDefaultStatus(msg);
|
||||
|
||||
// Disable menu entries for images, enable otherwise
|
||||
if (browser.documentContentType && BrowserUtils.mimeTypeIsTextBased(browser.documentContentType))
|
||||
if (browser.documentContentType && BrowserUtils.mimeTypeIsTextBased(browser.documentContentType)) {
|
||||
this.isImage.removeAttribute('disabled');
|
||||
else
|
||||
} else {
|
||||
canViewSource = false;
|
||||
this.isImage.setAttribute('disabled', 'true');
|
||||
}
|
||||
|
||||
if (canViewSource) {
|
||||
this.canViewSource.removeAttribute('disabled');
|
||||
} else {
|
||||
this.canViewSource.setAttribute('disabled', 'true');
|
||||
}
|
||||
}
|
||||
|
||||
this.isBusy = false;
|
||||
|
|
|
@ -475,6 +475,7 @@ skip-if = os == "linux" || e10s # Bug 1073339 - Investigate autocomplete test un
|
|||
[browser_urlbar_search_healthreport.js]
|
||||
[browser_urlbar_searchsettings.js]
|
||||
[browser_utilityOverlay.js]
|
||||
[browser_viewSourceInTabOnViewSource.js]
|
||||
[browser_visibleFindSelection.js]
|
||||
[browser_visibleLabel.js]
|
||||
[browser_visibleTabs.js]
|
||||
|
|
|
@ -0,0 +1,47 @@
|
|||
function* wait_while_tab_is_busy(tab) {
|
||||
yield BrowserTestUtils.waitForEvent(tab, "TabAttrModified", false,
|
||||
event => event.detail.changed.indexOf("busy") >= 0 &&
|
||||
!tab.hasAttribute("busy")
|
||||
);
|
||||
}
|
||||
|
||||
// This function waits for the tab to stop being busy instead of waiting for it
|
||||
// to load, since the canViewSource change happens at that time.
|
||||
let with_new_tab_opened = Task.async(function* (options, taskFn) {
|
||||
let tab = yield BrowserTestUtils.openNewForegroundTab(options.gBrowser, options.url, false);
|
||||
yield wait_while_tab_is_busy(tab);
|
||||
yield taskFn(tab.linkedBrowser);
|
||||
gBrowser.removeTab(tab);
|
||||
});
|
||||
|
||||
add_task(function*() {
|
||||
yield new Promise((resolve) => {
|
||||
SpecialPowers.pushPrefEnv({"set": [
|
||||
["view_source.tab", true],
|
||||
]}, resolve);
|
||||
});
|
||||
});
|
||||
|
||||
add_task(function* test_regular_page() {
|
||||
function* test_expect_view_source_enabled(browser) {
|
||||
ok(!XULBrowserWindow.canViewSource.hasAttribute("disabled"),
|
||||
"View Source should be enabled");
|
||||
}
|
||||
|
||||
yield with_new_tab_opened({
|
||||
gBrowser,
|
||||
url: "http://example.com",
|
||||
}, test_expect_view_source_enabled);
|
||||
});
|
||||
|
||||
add_task(function* test_view_source_page() {
|
||||
function* test_expect_view_source_disabled(browser) {
|
||||
ok(XULBrowserWindow.canViewSource.hasAttribute("disabled"),
|
||||
"View Source should be disabled");
|
||||
}
|
||||
|
||||
yield with_new_tab_opened({
|
||||
gBrowser,
|
||||
url: "view-source:http://example.com",
|
||||
}, test_expect_view_source_disabled);
|
||||
});
|
Загрузка…
Ссылка в новой задаче