Bug 1289974 - part 2: web-platform test; r?smaug draft
authorChun-Min Chang <chun.m.chang@gmail.com>
Mon, 07 Nov 2016 14:29:28 +0800
changeset 434701 e2f00be4a82c0fc6711325ee789b3efd61ea3d8f
parent 434700 14f1a449661b84bc4c07e0ff5d2d43bd3ea90f5d
child 536085 b6cbb3d3cbdbc15cd74fe96e9561bd7e6f16d4c2
push id34793
push userbmo:cchang@mozilla.com
push dateMon, 07 Nov 2016 06:34:23 +0000
reviewerssmaug
bugs1289974
milestone52.0a1
Bug 1289974 - part 2: web-platform test; r?smaug MozReview-Commit-ID: 8Dd9suVMBp2
dom/presentation/PresentationRequest.cpp
testing/web-platform/meta/presentation-api/controlling-ua/startNewPresentation_error.html.ini
--- a/dom/presentation/PresentationRequest.cpp
+++ b/dom/presentation/PresentationRequest.cpp
@@ -146,16 +146,24 @@ PresentationRequest::StartWithDevice(con
                                      ErrorResult& aRv)
 {
   nsCOMPtr<nsIGlobalObject> global = do_QueryInterface(GetOwner());
   if (NS_WARN_IF(!global)) {
     aRv.Throw(NS_ERROR_UNEXPECTED);
     return nullptr;
   }
 
+  // Drop the request if it's a receiver.
+  nsAutoString presentationURL;
+  nsContentUtils::GetPresentationURL(GetOwner()->GetDocShell(), presentationURL);
+  if (!presentationURL.IsEmpty()) {
+    aRv.Throw(NS_ERROR_DOM_INVALID_ACCESS_ERR);
+    return nullptr;
+  }
+
   // Get the origin.
   nsAutoString origin;
   nsresult rv = nsContentUtils::GetUTFOrigin(global->PrincipalOrNull(), origin);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     aRv.Throw(rv);
     return nullptr;
   }
 
--- a/testing/web-platform/meta/presentation-api/controlling-ua/startNewPresentation_error.html.ini
+++ b/testing/web-platform/meta/presentation-api/controlling-ua/startNewPresentation_error.html.ini
@@ -1,6 +1,7 @@
 [startNewPresentation_error.html]
   type: testharness
   prefs: [dom.presentation.enabled: true,
           dom.presentation.controller.enabled: true,
           dom.presentation.discovery.enabled: true,
+          dom.presentation.testing.simulate-receiver: true,
           dom.presentation.device.name: "Firefox"]