Bug 1519433 - Port bug 1513241: Adjust parameters of nsIWebNavigation.loadURI(). rs=bustage-fix
authorJorg K <jorgk@jorgk.com>
Fri, 11 Jan 2019 17:58:38 +0100
changeset 33312 77f1eb52e155
parent 33311 277f7d1fd552
child 33313 f751be7a1779
push id2368
push userclokep@gmail.com
push dateMon, 28 Jan 2019 21:12:50 +0000
treeherdercomm-beta@56d23c07d815 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbustage-fix
bugs1519433, 1513241
Bug 1519433 - Port bug 1513241: Adjust parameters of nsIWebNavigation.loadURI(). rs=bustage-fix
chat/content/convbrowser.xml
editor/ui/composer/content/editor.js
mail/components/compose/content/MsgComposeCommands.js
mailnews/base/prefs/content/AccountManager.js
mailnews/base/src/nsMessenger.cpp
mailnews/base/src/nsMsgPrintEngine.cpp
mailnews/base/src/nsMsgWindow.cpp
mailnews/extensions/newsblog/content/newsblogOverlay.js
--- a/chat/content/convbrowser.xml
+++ b/chat/content/convbrowser.xml
@@ -58,19 +58,20 @@
             this._messageDisplayPending = false;
 
             // _loadState is 0 while loading conv.html and 1 while
             // loading the real conversation HTML.
             this._loadState = 0;
 
             this.docShell.charset = "UTF-8";
             const URI = "chrome://chat/content/conv.html";
-            const flag = Ci.nsIWebNavigation.LOAD_FLAGS_NONE;
-            const systemPrincipal = Services.scriptSecurityManager.getSystemPrincipal();
-            this.webNavigation.loadURI(URI, flag, null, null, null, systemPrincipal);
+            const loadURIOptions = {
+              triggeringPrincipal: Services.scriptSecurityManager.getSystemPrincipal(),
+            };
+            this.webNavigation.loadURI(URI, loadURIOptions);
             this.addProgressListener(this);
 
             if (this._scrollingView)
               this._autoScrollPopup.hidePopup();
           ]]>
         </body>
       </method>
 
--- a/editor/ui/composer/content/editor.js
+++ b/editor/ui/composer/content/editor.js
@@ -400,23 +400,23 @@ var gEditorDocumentObserver =
 function SetFocusOnStartup()
 {
   gContentWindow.focus();
 }
 
 function EditorLoadUrl(url)
 {
   try {
-    if (url)
-      GetCurrentEditorElement().webNavigation.loadURI(url,  // uri string
-         Ci.nsIWebNavigation.LOAD_FLAGS_BYPASS_CACHE,       // load flags
-         null,                                              // referrer
-         null,                                              // post-data stream
-         null,
-         Services.scriptSecurityManager.getSystemPrincipal());
+    if (url) {
+      let loadURIOptions = {
+        loadFlags: Ci.nsIWebNavigation.LOAD_FLAGS_BYPASS_CACHE,
+        triggeringPrincipal: Services.scriptSecurityManager.getSystemPrincipal()
+      };
+      GetCurrentEditorElement().webNavigation.loadURI(url, loadURIOptions);
+    }
   } catch (e) { dump(" EditorLoadUrl failed: "+e+"\n"); }
 }
 
 // This should be called by all Composer types
 function EditorSharedStartup()
 {
   // Just for convenience
   gContentWindow = window.content;
--- a/mail/components/compose/content/MsgComposeCommands.js
+++ b/mail/components/compose/content/MsgComposeCommands.js
@@ -2869,18 +2869,20 @@ function ComposeStartup(aParams) {
 
   // Add an observer to be called when document is done loading,
   // which creates the editor.
   try {
     GetCurrentCommandManager().
             addCommandObserver(gMsgEditorCreationObserver, "obs_documentCreated");
 
     // Load empty page to create the editor.
-    editorElement.webNavigation.loadURI("about:blank", 0, null, null, null,
-      Services.scriptSecurityManager.getSystemPrincipal());
+    let loadURIOptions = {
+      triggeringPrincipal: Services.scriptSecurityManager.getSystemPrincipal(),
+    };
+    editorElement.webNavigation.loadURI("about:blank", loadURIOptions);
   } catch (e) {
     Cu.reportError(e);
   }
 
   gEditingDraft = gMsgCompose.compFields.draftId;
 
   // finally, see if we need to auto open the address sidebar.
   var sideBarBox = document.getElementById("sidebar-box");
--- a/mailnews/base/prefs/content/AccountManager.js
+++ b/mailnews/base/prefs/content/AccountManager.js
@@ -1147,20 +1147,21 @@ function pageURL(pageId)
   catch (ex) {
     chromePackageName = "messenger";
   }
   return "chrome://" + chromePackageName + "/content/" + pageId;
 }
 
 function loadPage(pageId)
 {
-  const LOAD_FLAGS_NONE = Ci.nsIWebNavigation.LOAD_FLAGS_NONE;
-  document.getElementById("contentFrame").webNavigation.loadURI(pageURL(pageId),
-    LOAD_FLAGS_NONE, null, null, null,
-    Services.scriptSecurityManager.getSystemPrincipal());
+  const loadURIOptions = {
+    triggeringPrincipal: Services.scriptSecurityManager.getSystemPrincipal(),
+  };
+  document.getElementById("contentFrame")
+          .webNavigation.loadURI(pageURL(pageId), loadURIOptions);
 }
 
 // save the values of the widgets to the given server
 function savePage(account)
 {
   if (!account)
     return;
 
--- a/mailnews/base/src/nsMessenger.cpp
+++ b/mailnews/base/src/nsMessenger.cpp
@@ -13,16 +13,17 @@
 #include "nsIStringStream.h"
 #include "nsLocalFile.h"
 #include "nsDirectoryServiceDefs.h"
 #include "nsQuickSort.h"
 #include "nsNativeCharsetUtils.h"
 #include "nsIMutableArray.h"
 #include "mozilla/Path.h"
 #include "mozilla/Services.h"
+#include "mozilla/dom/LoadURIOptionsBinding.h"
 
 // necko
 #include "nsMimeTypes.h"
 #include "nsIURL.h"
 #include "nsIPrompt.h"
 #include "nsIStreamListener.h"
 #include "nsIStreamConverterService.h"
 #include "nsNetUtil.h"
@@ -470,22 +471,20 @@ nsMessenger::OpenURL(const nsACString& a
     AddMsgUrlToNavigateHistory(aURL);
     mLastDisplayURI = aURL; // remember the last uri we displayed....
     return NS_OK;
   }
 
   nsCOMPtr<nsIWebNavigation> webNav(do_QueryInterface(mDocShell));
   if(!webNav)
     return NS_ERROR_FAILURE;
-  rv = webNav->LoadURI(NS_ConvertASCIItoUTF16(aURL),          // URI string
-                       nsIWebNavigation::LOAD_FLAGS_IS_LINK,  // Load flags
-                       nullptr,                               // Referring URI
-                       nullptr,                               // Post stream
-                       nullptr,                               // Extra headers
-                       nsContentUtils::GetSystemPrincipal());
+  mozilla::dom::LoadURIOptions loadURIOptions;
+  loadURIOptions.mLoadFlags = nsIWebNavigation::LOAD_FLAGS_IS_LINK;
+  loadURIOptions.mTriggeringPrincipal = nsContentUtils::GetSystemPrincipal();
+  rv = webNav->LoadURI(NS_ConvertASCIItoUTF16(aURL), loadURIOptions);
   return rv;
 }
 
 NS_IMETHODIMP nsMessenger::LaunchExternalURL(const nsACString& aURL)
 {
   nsresult rv;
 
   nsCOMPtr<nsIURI> uri;
--- a/mailnews/base/src/nsMsgPrintEngine.cpp
+++ b/mailnews/base/src/nsMsgPrintEngine.cpp
@@ -24,16 +24,17 @@
 #include "nsIInterfaceRequestorUtils.h"
 #include "nsMsgPrintEngine.h"
 #include "nsIDocumentLoader.h"
 #include "nsIPrefService.h"
 #include "nsIPrefBranch.h"
 #include "nsThreadUtils.h"
 #include "nsAutoPtr.h"
 #include "mozilla/Services.h"
+#include "mozilla/dom/LoadURIOptionsBinding.h"
 
 // Interfaces Needed
 #include "nsIBaseWindow.h"
 #include "nsIDocShellTreeOwner.h"
 #include "nsIDocShellTreeItem.h"
 #include "nsIWebNavigation.h"
 #include "nsContentUtils.h"
 #include "nsIChannel.h"
@@ -485,23 +486,21 @@ nsMsgPrintEngine::FireThatLoadOperation(
     nsCOMPtr<nsIURI> dummyNull;
     rv = messageService->DisplayMessageForPrinting(uriCStr.get(), mDocShell, nullptr, nullptr,
                                                    getter_AddRefs(dummyNull));
   }
   //If it's not something we know about, then just load try loading it directly.
   else
   {
     nsCOMPtr<nsIWebNavigation> webNav(do_QueryInterface(mDocShell));
-    if (webNav)
-      rv = webNav->LoadURI(uri,                                // URI string
-                           nsIWebNavigation::LOAD_FLAGS_NONE,  // Load flags
-                           nullptr,                            // Referring URI
-                           nullptr,                            // Post data
-                           nullptr,                            // Extra headers
-                           nsContentUtils::GetSystemPrincipal());
+    if (webNav) {
+      mozilla::dom::LoadURIOptions loadURIOptions;
+      loadURIOptions.mTriggeringPrincipal = nsContentUtils::GetSystemPrincipal();
+      rv = webNav->LoadURI(uri, loadURIOptions);
+    }
   }
   return rv;
 }
 
 void
 nsMsgPrintEngine::InitializeDisplayCharset()
 {
   // libmime always converts to UTF-8 (both HTML and XML)
--- a/mailnews/base/src/nsMsgWindow.cpp
+++ b/mailnews/base/src/nsMsgWindow.cpp
@@ -29,16 +29,17 @@
 #include "nsIWebNavigation.h"
 #include "nsContentUtils.h"
 #include "nsMsgContentPolicy.h"
 #include "nsComponentManagerUtils.h"
 #include "nsServiceManagerUtils.h"
 #include "nsIAuthPrompt.h"
 #include "nsMsgUtils.h"
 #include "mozilla/TransactionManager.h"
+#include "mozilla/dom/LoadURIOptionsBinding.h"
 
 NS_IMPL_ISUPPORTS(nsMsgWindow,
                               nsIMsgWindow,
                               nsIURIContentListener,
                               nsISupportsWeakReference,
                               nsIMsgWindowTest)
 
 nsMsgWindow::nsMsgWindow()
@@ -500,19 +501,19 @@ nsMsgWindow::DisplayURIInMessagePane(con
 
   nsCOMPtr <nsIDocShell> docShell;
   GetMessageWindowDocShell(getter_AddRefs(docShell));
   NS_ENSURE_TRUE(docShell, NS_ERROR_FAILURE);
 
   nsCOMPtr<nsIWebNavigation> webNav(do_QueryInterface(docShell));
   NS_ENSURE_TRUE(webNav, NS_ERROR_FAILURE);
 
-  return webNav->LoadURI(uri, nsIWebNavigation::LOAD_FLAGS_NONE,
-                         nullptr, nullptr, nullptr,
-                         principal);
+  mozilla::dom::LoadURIOptions loadURIOptions;
+  loadURIOptions.mTriggeringPrincipal = principal;
+  return webNav->LoadURI(uri, loadURIOptions);
 }
 
 NS_IMETHODIMP
 nsMsgWindow::DisplayHTMLInMessagePane(const nsAString& title, const nsAString& body, bool clearMsgHdr)
 {
   nsString htmlStr;
   htmlStr.AppendLiteral(u"<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"></head><body>");
   htmlStr.Append(body);
--- a/mailnews/extensions/newsblog/content/newsblogOverlay.js
+++ b/mailnews/extensions/newsblog/content/newsblogOverlay.js
@@ -216,19 +216,20 @@ var FeedMessageHandler = {
                              "invalid Content-Base header url - " + url);
           return;
         }
         if (aWhere.browser) {
           Cc["@mozilla.org/uriloader/external-protocol-service;1"]
             .getService(Ci.nsIExternalProtocolService)
             .loadURI(uri);
         } else if (aWhere.messagepane) {
-          let loadFlag = getBrowser().webNavigation.LOAD_FLAGS_NONE;
-          getBrowser().webNavigation.loadURI(url, loadFlag, null, null, null,
-            Services.scriptSecurityManager.getSystemPrincipal());
+          let loadURIOptions = {
+            triggeringPrincipal: Services.scriptSecurityManager.getSystemPrincipal(),
+          };
+          getBrowser().webNavigation.loadURI(url, loadURIOptions);
         } else if (aWhere.tab) {
           openContentTab(url, "tab", "^");
         } else if (aWhere.window) {
           openContentTab(url, "window", "^");
         }
       } else {
         FeedUtils.log.info("FeedMessageHandler.loadWebPage: could not get " +
                            "Content-Base header url for this message");