summaryrefslogtreecommitdiffstats
path: root/application
diff options
context:
space:
mode:
authorjanekptacijarabaci <janekptacijarabaci@seznam.cz>2018-04-13 06:17:25 +0200
committerjanekptacijarabaci <janekptacijarabaci@seznam.cz>2018-04-13 06:17:25 +0200
commit7bbe1c3f3db8028e4592c4dfdfbd473eec34705d (patch)
tree6237cbdf313705e3996b2bb9769a3f6f81e15e9e /application
parente226e36a6c1792b68ba22a2ae43b8e1e230b5246 (diff)
downloadUXP-7bbe1c3f3db8028e4592c4dfdfbd473eec34705d.tar
UXP-7bbe1c3f3db8028e4592c4dfdfbd473eec34705d.tar.gz
UXP-7bbe1c3f3db8028e4592c4dfdfbd473eec34705d.tar.lz
UXP-7bbe1c3f3db8028e4592c4dfdfbd473eec34705d.tar.xz
UXP-7bbe1c3f3db8028e4592c4dfdfbd473eec34705d.zip
Fix: Using "View Source" from Browser Console
Issue #121
Diffstat (limited to 'application')
-rw-r--r--application/palemoon/base/content/browser.js70
1 files changed, 32 insertions, 38 deletions
diff --git a/application/palemoon/base/content/browser.js b/application/palemoon/base/content/browser.js
index 8cc091e85..8b3fa0b4f 100644
--- a/application/palemoon/base/content/browser.js
+++ b/application/palemoon/base/content/browser.js
@@ -2017,49 +2017,43 @@ function readFromClipboard()
return url;
}
-function BrowserViewSourceOfDocument(aDocument)
+function BrowserViewSourceOfDocument(aArgsOrDocument)
{
- var pageCookie;
- var webNav;
-
- // Get the document charset
- var docCharset = "charset=" + aDocument.characterSet;
-
- // Get the nsIWebNavigation associated with the document
- try {
- var win;
- var ifRequestor;
-
- // Get the DOMWindow for the requested document. If the DOMWindow
- // cannot be found, then just use the content window...
- //
- // XXX: This is a bit of a hack...
- win = aDocument.defaultView;
- if (win == window) {
- win = content;
- }
- ifRequestor = win.QueryInterface(Components.interfaces.nsIInterfaceRequestor);
-
- webNav = ifRequestor.getInterface(nsIWebNavigation);
- } catch(err) {
- // If nsIWebNavigation cannot be found, just get the one for the whole
- // window...
- webNav = gBrowser.webNavigation;
+ let args;
+
+ if (aArgsOrDocument instanceof Document) {
+ let doc = aArgsOrDocument;
+
+ let requestor = doc.defaultView
+ .QueryInterface(Ci.nsIInterfaceRequestor);
+ let browser = requestor.getInterface(Ci.nsIWebNavigation)
+ .QueryInterface(Ci.nsIDocShell)
+ .chromeEventHandler;
+ let outerWindowID = requestor.getInterface(Ci.nsIDOMWindowUtils)
+ .outerWindowID;
+ let URL = browser.currentURI.spec;
+ args = { browser, outerWindowID, URL };
+ } else {
+ args = aArgsOrDocument;
}
- //
- // Get the 'PageDescriptor' for the current document. This allows the
- // view-source to access the cached copy of the content rather than
- // refetching it from the network...
- //
- try{
- var PageLoader = webNav.QueryInterface(Components.interfaces.nsIWebPageDescriptor);
- pageCookie = PageLoader.currentDescriptor;
- } catch(err) {
- // If no page descriptor is available, just use the view-source URL...
+ let viewInternal = () => {
+ top.gViewSourceUtils.viewSource(args);
}
- top.gViewSourceUtils.viewSource(webNav.currentURI.spec, pageCookie, aDocument);
+ // Check if external view source is enabled. If so, try it. If it fails,
+ // fallback to internal view source.
+ if (Services.prefs.getBoolPref("view_source.editor.external")) {
+ top.gViewSourceUtils
+ .openInExternalEditor(args, null, null, null, result => {
+ if (!result) {
+ viewInternal();
+ }
+ });
+ } else {
+ // Display using internal view source
+ viewInternal();
+ }
}
// doc - document to use for source, or null for this window's document