Bug 1348874 - If origin is an opaque origin, reject promise with a TypeError, r=janv
authorShawn Huang <shuang@mozilla.com>
Mon, 17 Apr 2017 15:07:15 +0800
changeset 353394 aa2f6f1f7bd62a9286f9b39d259a4ace994512e2
parent 353393 fe9127b627b80a73e076a0bd7c08677c1d233c0c
child 353395 1574c02ea13ff124565754192b19950480ce917e
push id89247
push usershuang@mozilla.com
push dateMon, 17 Apr 2017 07:07:30 +0000
treeherdermozilla-inbound@aa2f6f1f7bd6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjanv
bugs1348874
milestone55.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 1348874 - If origin is an opaque origin, reject promise with a TypeError, r=janv
dom/quota/StorageManager.cpp
--- a/dom/quota/StorageManager.cpp
+++ b/dom/quota/StorageManager.cpp
@@ -282,16 +282,23 @@ ExecuteOpOnMainOrWorkerThread(nsIGlobalO
     if (NS_WARN_IF(!doc)) {
       aRv.Throw(NS_ERROR_FAILURE);
       return nullptr;
     }
 
     nsCOMPtr<nsIPrincipal> principal = doc->NodePrincipal();
     MOZ_ASSERT(principal);
 
+    // Storage Standard 7. API
+    // If origin is an opaque origin, then reject promise with a TypeError.
+    if (principal->GetIsNullPrincipal()) {
+      promise->MaybeReject(NS_ERROR_DOM_TYPE_ERR);
+      return promise.forget();
+    }
+
     switch (aType) {
       case RequestResolver::Type::Persisted: {
         RefPtr<RequestResolver> resolver =
           new RequestResolver(RequestResolver::Type::Persisted, promise);
 
         RefPtr<nsIQuotaRequest> request;
         aRv = Persisted(principal, resolver, getter_AddRefs(request));