Bug 1380156 - Loading temporary unpacked extension breaks extension page's CSS in OOP Extensions. r=jimm
authorHaik Aftandilian <haftandilian@mozilla.com>
Tue, 25 Jul 2017 22:27:30 -0700
changeset 419833 ee7761772725d1c985112aebe792b3fd032a1d0a
parent 419832 93bdd4766ea3d7be4c53357b3ff4de770b2a6145
child 419834 6f27d2157170d46c8ac75a9778542e250c21c839
push id7566
push usermtabara@mozilla.com
push dateWed, 02 Aug 2017 08:25:16 +0000
treeherdermozilla-beta@86913f512c3c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjimm
bugs1380156
milestone56.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1380156 - Loading temporary unpacked extension breaks extension page's CSS in OOP Extensions. r=jimm MozReview-Commit-ID: 3SskOcpAI5Z
netwerk/protocol/res/ExtensionProtocolHandler.cpp
--- a/netwerk/protocol/res/ExtensionProtocolHandler.cpp
+++ b/netwerk/protocol/res/ExtensionProtocolHandler.cpp
@@ -598,34 +598,48 @@ ExtensionProtocolHandler::NewStream(nsIU
 
   bool isDirectory = false;
   NS_TRY(extensionDir->IsDirectory(&isDirectory));
   if (!isDirectory) {
     // The host should map to a directory for unpacked extensions
     return Err(NS_ERROR_FILE_NOT_DIRECTORY);
   }
 
-  /*
-   * Now get a channel for the resolved child URI and make sure the
-   * channel is a file channel.
-   */
+  // Make sure the child URI resolves to a file URI then get a file
+  // channel for the request. The resultant channel should be a
+  // file channel because we only request remote streams for unpacked
+  // extension resource loads where the URI resolves to a file.
+  nsAutoCString resolvedSpec;
+  NS_TRY(ResolveURI(aChildURI, resolvedSpec));
+
+  nsAutoCString resolvedScheme;
+  NS_TRY(net_ExtractURLScheme(resolvedSpec, resolvedScheme));
+  if (!resolvedScheme.EqualsLiteral("file")) {
+    return Err(NS_ERROR_UNEXPECTED);
+  }
+
+  nsCOMPtr<nsIIOService> ioService = do_GetIOService(&rv);
+  NS_TRY(rv);
+
+  nsCOMPtr<nsIURI> resolvedURI;
+  NS_TRY(ioService->NewURI(resolvedSpec,
+                           nullptr,
+                           nullptr,
+                           getter_AddRefs(resolvedURI)));
 
   // We use the system principal to get a file channel for the request,
   // but only after we've checked (above) that the child URI is of
   // moz-extension scheme and that the URI host maps to a directory.
   nsCOMPtr<nsIChannel> channel;
   NS_TRY(NS_NewChannel(getter_AddRefs(channel),
-                       aChildURI,
+                       resolvedURI,
                        nsContentUtils::GetSystemPrincipal(),
                        nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL,
                        nsIContentPolicy::TYPE_OTHER));
 
-  // Channel should be a file channel. It should never be a JAR
-  // channel because we only request remote streams for unpacked
-  // extension resource loads where the URI resolves to a file.
   nsCOMPtr<nsIFileChannel> fileChannel = do_QueryInterface(channel, &rv);
   NS_TRY(rv);
 
   nsCOMPtr<nsIFile> requestedFile;
   NS_TRY(fileChannel->GetFile(getter_AddRefs(requestedFile)));
 
   /*
    * Make sure the file we resolved to is within the extension directory.