getUserMedia requests from the main frame should be treated the same as requests...
authorjonlee@apple.com <jonlee@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 13 Mar 2016 19:51:39 +0000 (19:51 +0000)
committerjonlee@apple.com <jonlee@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 13 Mar 2016 19:51:39 +0000 (19:51 +0000)
https://bugs.webkit.org/show_bug.cgi?id=155405
<rdar://problem/25131007>

Reviewed by Eric Carlson.

When gUM is called from the main frame, or from a subframe with the same origin, the
top level document origin should be the same.

* Modules/mediastream/UserMediaRequest.cpp:
(WebCore::UserMediaRequest::userMediaDocumentOrigin): Reverse the logic so that it is similar
to topLevelDocumentOrigin.
(WebCore::UserMediaRequest::topLevelDocumentOrigin): Return the top origin always.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@198082 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/Modules/mediastream/UserMediaRequest.cpp

index 58745ad..f5bf54d 100644 (file)
@@ -1,3 +1,19 @@
+2016-03-13  Jon Lee  <jonlee@apple.com>
+
+        getUserMedia requests from the main frame should be treated the same as requests from an iframe with the same origin
+        https://bugs.webkit.org/show_bug.cgi?id=155405
+        <rdar://problem/25131007>
+
+        Reviewed by Eric Carlson.
+
+        When gUM is called from the main frame, or from a subframe with the same origin, the
+        top level document origin should be the same.
+
+        * Modules/mediastream/UserMediaRequest.cpp:
+        (WebCore::UserMediaRequest::userMediaDocumentOrigin): Reverse the logic so that it is similar
+        to topLevelDocumentOrigin.
+        (WebCore::UserMediaRequest::topLevelDocumentOrigin): Return the top origin always.
+
 2016-03-13  David Kilzer  <ddkilzer@apple.com>
 
         REGRESSION (r198079): Windows build broke because of "%PRId64" format specifier
index 31ae479..73b149b 100644 (file)
@@ -108,10 +108,10 @@ UserMediaRequest::~UserMediaRequest()
 
 SecurityOrigin* UserMediaRequest::userMediaDocumentOrigin() const
 {
-    if (m_scriptExecutionContext)
-        return m_scriptExecutionContext->securityOrigin();
+    if (!m_scriptExecutionContext)
+        return nullptr;
 
-    return nullptr;
+    return m_scriptExecutionContext->securityOrigin();
 }
 
 SecurityOrigin* UserMediaRequest::topLevelDocumentOrigin() const
@@ -119,11 +119,6 @@ SecurityOrigin* UserMediaRequest::topLevelDocumentOrigin() const
     if (!m_scriptExecutionContext)
         return nullptr;
 
-    if (Frame* frame = downcast<Document>(*scriptExecutionContext()).frame()) {
-        if (frame->isMainFrame())
-            return nullptr;
-    }
-
     return m_scriptExecutionContext->topOrigin();
 }