Bug 1289974 - part 2: web-platform test; r?smaug
MozReview-Commit-ID: 8Dd9suVMBp2
--- 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"]