diff --git a/mozilla/editor/ui/composer/content/editorApplicationOverlay.js b/mozilla/editor/ui/composer/content/editorApplicationOverlay.js index b6874806ec0..3b9612f5366 100644 --- a/mozilla/editor/ui/composer/content/editorApplicationOverlay.js +++ b/mozilla/editor/ui/composer/content/editorApplicationOverlay.js @@ -58,12 +58,6 @@ function initEditorContextMenuListener(aEvent) addEventListener("load", initEditorContextMenuListener, false); -function editLink(aLinkURL) -{ - urlSecurityCheck(aLinkURL, window.document); // XXX what is this? Why do we pass the chrome doc? - editPage(aLinkURL, window, false); -} - function editDocument(aDocument) { if (!aDocument) @@ -74,12 +68,8 @@ function editDocument(aDocument) function editPageOrFrame() { - var url; var focusedWindow = document.commandDispatcher.focusedWindow; - if (isDocumentFrame(focusedWindow)) - url = focusedWindow.location.href; - else - url = window._content.location.href; + var url = getContentFrameURI(focusedWindow); editPage(url, window, false) } @@ -92,8 +82,8 @@ function editPageOrFrame() function editPage(url, launchWindow, delay) { var focusedWindow = document.commandDispatcher.focusedWindow; - if (isDocumentFrame(focusedWindow)) - url = focusedWindow.location.href; + if (isContentFrame(focusedWindow)) + url = Components.lookupMethod(focusedWindow, 'location').call(focusedWindow).href; // Always strip off "view-source:" if (url.slice(0,12) == "view-source:") diff --git a/mozilla/xpfe/browser/resources/content/navigator.js b/mozilla/xpfe/browser/resources/content/navigator.js index 79d2459d3fc..f78d88364f0 100644 --- a/mozilla/xpfe/browser/resources/content/navigator.js +++ b/mozilla/xpfe/browser/resources/content/navigator.js @@ -209,7 +209,7 @@ function loadEventHandlers(event) function getContentAreaFrameCount() { var saveFrameItem = document.getElementById("savepage"); - if (!_content || !_content.frames.length || !isDocumentFrame(document.commandDispatcher.focusedWindow)) + if (!content || !content.frames.length || !isContentFrame(document.commandDispatcher.focusedWindow)) saveFrameItem.setAttribute("hidden", "true"); else saveFrameItem.removeAttribute("hidden"); @@ -219,8 +219,8 @@ function getContentAreaFrameCount() function contentAreaFrameFocus() { var focusedWindow = document.commandDispatcher.focusedWindow; - if (isDocumentFrame(focusedWindow)) { - gFocusedURL = focusedWindow.location.href; + if (isContentFrame(focusedWindow)) { + gFocusedURL = Components.lookupMethod(focusedWindow, 'location').call(focusedWindow).href; gFocusedDocument = focusedWindow.document; } } diff --git a/mozilla/xpfe/communicator/resources/content/contentAreaClick.js b/mozilla/xpfe/communicator/resources/content/contentAreaClick.js index 5dd92504db6..e21a4546919 100644 --- a/mozilla/xpfe/communicator/resources/content/contentAreaClick.js +++ b/mozilla/xpfe/communicator/resources/content/contentAreaClick.js @@ -206,6 +206,9 @@ function handleLinkClick(event, href, linkNode) { + // Make sure we are allowed to open this URL + urlSecurityCheck(href, document); + switch (event.button) { case 0: // if left button clicked if (event.metaKey || event.ctrlKey) { // and meta or ctrl are down diff --git a/mozilla/xpfe/communicator/resources/content/contentAreaUtils.js b/mozilla/xpfe/communicator/resources/content/contentAreaUtils.js index 176b1bc0818..5fc1232d4b8 100644 --- a/mozilla/xpfe/communicator/resources/content/contentAreaUtils.js +++ b/mozilla/xpfe/communicator/resources/content/contentAreaUtils.js @@ -40,38 +40,40 @@ * Determine whether or not a given focused DOMWindow is in the content * area. **/ -function isDocumentFrame(aFocusedWindow) +function isContentFrame(aFocusedWindow) { - var contentFrames = _content.frames; - if (contentFrames.length) { - for (var i = 0; i < contentFrames.length; ++i) { - if (aFocusedWindow == contentFrames[i]) - return true; - } - } - return false; + var focusedTop = Components.lookupMethod(aFocusedWindow, 'top') + .call(aFocusedWindow); + + return (focusedTop == window.content); } function urlSecurityCheck(url, doc) { // URL Loading Security Check var focusedWindow = doc.commandDispatcher.focusedWindow; - var sourceWin = isDocumentFrame(focusedWindow) ? focusedWindow.location.href : focusedWindow._content.location.href; + var sourceURL = getContentFrameURI(focusedWindow); const nsIScriptSecurityManager = Components.interfaces.nsIScriptSecurityManager; - var secMan = Components.classes["@mozilla.org/scriptsecuritymanager;1"].getService(). - QueryInterface(nsIScriptSecurityManager); + var secMan = Components.classes["@mozilla.org/scriptsecuritymanager;1"] + .getService(nsIScriptSecurityManager); try { - secMan.checkLoadURIStr(sourceWin, url, nsIScriptSecurityManager.STANDARD); + secMan.checkLoadURIStr(sourceURL, url, nsIScriptSecurityManager.STANDARD); } catch (e) { - throw "Load of " + url + " denied."; + throw "Load of " + url + " denied."; } } +function getContentFrameURI(aFocusedWindow) +{ + var contentFrame = isContentFrame(aFocusedWindow) ? aFocusedWindow : window.content; + return Components.lookupMethod(contentFrame, 'location').call(contentFrame).href; +} + function getReferrer(doc) { var focusedWindow = doc.commandDispatcher.focusedWindow; - var sourceURL = - isDocumentFrame(focusedWindow) ? focusedWindow.location.href : focusedWindow._content.location.href; + var sourceURL = getContentFrameURI(focusedWindow); + try { var uri = Components.classes["@mozilla.org/network/standard-url;1"].createInstance(Components.interfaces.nsIURI); uri.spec = sourceURL; @@ -156,7 +158,7 @@ function saveURL(aURL, aFileName, aFilePickerTitleKey, aShouldBypassCache) function saveFrameDocument() { var focusedWindow = document.commandDispatcher.focusedWindow; - if (isDocumentFrame(focusedWindow)) + if (isContentFrame(focusedWindow)) saveDocument(focusedWindow.document); }