Commit 21c1f22b authored by Eden Chuang's avatar Eden Chuang
Browse files

Bug 1721897 - Getting the top same process parent document's principal for payment request. r=kmag

parent e5de072e
Loading
Loading
Loading
Loading
+11 −4
Original line number Diff line number Diff line
@@ -610,10 +610,17 @@ already_AddRefed<PaymentRequest> PaymentRequest::Constructor(
    return nullptr;
  }

  // Get the top level principal
  RefPtr<Document> topLevelDoc = doc->GetTopLevelContentDocumentIfSameProcess();
  MOZ_ASSERT(topLevelDoc);
  nsCOMPtr<nsIPrincipal> topLevelPrincipal = topLevelDoc->NodePrincipal();
  // Get the top same process document
  nsCOMPtr<Document> topSameProcessDoc = doc;
  topSameProcessDoc = doc;
  while (topSameProcessDoc) {
    nsCOMPtr<Document> parent = topSameProcessDoc->GetInProcessParentDocument();
    if (!parent || !parent->IsContentDocument()) {
      break;
    }
    topSameProcessDoc = parent;
  }
  nsCOMPtr<nsIPrincipal> topLevelPrincipal = topSameProcessDoc->NodePrincipal();

  // Check payment methods and details
  IsValidMethodData(aGlobal.Context(), aMethodData, aRv);