Skip to content
Permalink
Browse files
REGRESSION?(r202466): http/tests/security/canvas-remote-read-remote-v…
…ideo-redirect.html failing on Sierra

https://bugs.webkit.org/show_bug.cgi?id=159172
<rdar://problem/27030025>

Reviewed by Brent Fulgham.

Add a hasSingleSecurityOrigin property to WebCoreNSURLSession that gets updated each time one of that
sessions' tasks receieves a response or a redirect request. Check that property from the MediaPlayerPrivate.

* platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
(WebCore::MediaPlayerPrivateAVFoundationObjC::hasSingleSecurityOrigin):
* platform/network/cocoa/WebCoreNSURLSession.h:
* platform/network/cocoa/WebCoreNSURLSession.mm:
(-[WebCoreNSURLSession updateHasSingleSecurityOrigin:]):
(-[WebCoreNSURLSession dataTaskWithRequest:]):
(-[WebCoreNSURLSession dataTaskWithURL:]):
(-[WebCoreNSURLSessionDataTask resource:receivedResponse:]):
(-[WebCoreNSURLSessionDataTask resource:receivedRedirect:request:]):


Canonical link: https://commits.webkit.org/177271@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@202520 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
jernoble committed Jun 27, 2016
1 parent 24fe72c commit 35bacb5922f0fe8320b22bd1c4a57503f1add0cf
@@ -1,3 +1,24 @@
2016-06-27 Jer Noble <jer.noble@apple.com>

REGRESSION?(r202466): http/tests/security/canvas-remote-read-remote-video-redirect.html failing on Sierra
https://bugs.webkit.org/show_bug.cgi?id=159172
<rdar://problem/27030025>

Reviewed by Brent Fulgham.

Add a hasSingleSecurityOrigin property to WebCoreNSURLSession that gets updated each time one of that
sessions' tasks receieves a response or a redirect request. Check that property from the MediaPlayerPrivate.

* platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
(WebCore::MediaPlayerPrivateAVFoundationObjC::hasSingleSecurityOrigin):
* platform/network/cocoa/WebCoreNSURLSession.h:
* platform/network/cocoa/WebCoreNSURLSession.mm:
(-[WebCoreNSURLSession updateHasSingleSecurityOrigin:]):
(-[WebCoreNSURLSession dataTaskWithRequest:]):
(-[WebCoreNSURLSession dataTaskWithURL:]):
(-[WebCoreNSURLSessionDataTask resource:receivedResponse:]):
(-[WebCoreNSURLSessionDataTask resource:receivedRedirect:request:]):

2016-06-27 Benjamin Poulain <benjamin@webkit.org>

Fix style invalidation for :active when the activated node has no renderer
@@ -2241,7 +2241,18 @@ void determineChangedTracksFromNewTracksAndOldItems(MediaSelectionGroupAVFObjC*

Ref<SecurityOrigin> resolvedOrigin(SecurityOrigin::create(resolvedURL()));
Ref<SecurityOrigin> requestedOrigin(SecurityOrigin::createFromString(assetURL()));
return resolvedOrigin.get().isSameSchemeHostPort(&requestedOrigin.get());
if (!resolvedOrigin.get().isSameSchemeHostPort(&requestedOrigin.get()))
return false;

#if PLATFORM(IOS) || __MAC_OS_X_VERSION_MIN_REQUIRED > 101100
AVAssetResourceLoader *resourceLoader = m_avAsset.get().resourceLoader;
if (Settings::isAVFoundationNSURLSessionEnabled() && [resourceLoader respondsToSelector:@selector(URLSession)]) {
WebCoreNSURLSession *session = (WebCoreNSURLSession *)resourceLoader.URLSession;
if ([session respondsToSelector:@selector(hasSingleSecurityOrigin)])
return session.hasSingleSecurityOrigin;
}
#endif
return true;
}

bool MediaPlayerPrivateAVFoundationObjC::didPassCORSAccessCheck() const
@@ -46,6 +46,7 @@ class CachedResourceRequest;
class PlatformMediaResource;
class PlatformMediaResourceLoader;
class WebCoreNSURLSessionDataTaskClient;
class SecurityOrigin;
}

enum class WebCoreNSURLSessionCORSAccessCheckResults {
@@ -63,16 +64,19 @@ WEBCORE_EXPORT @interface WebCoreNSURLSession : NSObject {
NSString *_sessionDescription;
HashSet<RetainPtr<WebCoreNSURLSessionDataTask>> _dataTasks;
BOOL _invalidated;
BOOL _hasSingleSecurityOrigin;
NSUInteger _nextTaskIdentifier;
OSObjectPtr<dispatch_queue_t> _internalQueue;
WebCoreNSURLSessionCORSAccessCheckResults _corsResults;
RefPtr<WebCore::SecurityOrigin> _requestedOrigin;
}
- (id)initWithResourceLoader:(WebCore::PlatformMediaResourceLoader&)loader delegate:(id<NSURLSessionTaskDelegate>)delegate delegateQueue:(NSOperationQueue*)queue;
@property (readonly, retain) NSOperationQueue *delegateQueue;
@property (nullable, readonly, retain) id <NSURLSessionDelegate> delegate;
@property (readonly, copy) NSURLSessionConfiguration *configuration;
@property (copy) NSString *sessionDescription;
@property (readonly) BOOL didPassCORSAccessChecks;
@property (readonly) BOOL hasSingleSecurityOrigin;
- (void)finishTasksAndInvalidate;
- (void)invalidateAndCancel;

@@ -30,6 +30,7 @@

#import "CachedResourceRequest.h"
#import "PlatformMediaResourceLoader.h"
#import "SecurityOrigin.h"
#import "SubresourceLoader.h"

using namespace WebCore;
@@ -44,6 +45,7 @@ @interface WebCoreNSURLSession ()
- (void)taskCompleted:(WebCoreNSURLSessionDataTask *)task;
- (void)addDelegateOperation:(void (^)(void))operation;
- (void)task:(WebCoreNSURLSessionDataTask *)task didReceiveCORSAccessCheckResult:(BOOL)result;
- (void)updateHasSingleSecurityOrigin:(SecurityOrigin&)origin;
@end

@interface WebCoreNSURLSessionDataTask ()
@@ -83,6 +85,7 @@ - (id)initWithResourceLoader:(PlatformMediaResourceLoader&)loader delegate:(id<N
self.delegate = inDelegate;
_queue = inQueue ? inQueue : [NSOperationQueue mainQueue];
_internalQueue = adoptOSObject(dispatch_queue_create("WebCoreNSURLSession _internalQueue", DISPATCH_QUEUE_SERIAL));
_hasSingleSecurityOrigin = YES;

return self;
}
@@ -139,6 +142,17 @@ - (void)task:(WebCoreNSURLSessionDataTask *)task didReceiveCORSAccessCheckResult
_corsResults = WebCoreNSURLSessionCORSAccessCheckResults::Pass;
}

- (void)updateHasSingleSecurityOrigin:(SecurityOrigin&)origin
{
if (!_requestedOrigin) {
_requestedOrigin = &origin;
return;
}

if (!origin.isSameSchemeHostPort(_requestedOrigin.get()))
_hasSingleSecurityOrigin = false;
}

#pragma mark - NSURLSession API
@synthesize sessionDescription=_sessionDescription;
@dynamic delegate;
@@ -234,6 +248,8 @@ - (NSURLSessionDataTask *)dataTaskWithRequest:(NSURLRequest *)request
if (_invalidated)
return nil;

[self updateHasSingleSecurityOrigin:SecurityOrigin::create([request URL])];

WebCoreNSURLSessionDataTask *task = [[WebCoreNSURLSessionDataTask alloc] initWithSession:self identifier:_nextTaskIdentifier++ request:request];
_dataTasks.add(task);
return (NSURLSessionDataTask *)[task autorelease];
@@ -244,6 +260,8 @@ - (NSURLSessionDataTask *)dataTaskWithURL:(NSURL *)url
if (_invalidated)
return nil;

[self updateHasSingleSecurityOrigin:SecurityOrigin::create(url)];

WebCoreNSURLSessionDataTask *task = [[WebCoreNSURLSessionDataTask alloc] initWithSession:self identifier:_nextTaskIdentifier++ URL:url];
_dataTasks.add(task);
return (NSURLSessionDataTask *)[task autorelease];
@@ -524,6 +542,7 @@ - (void)resource:(PlatformMediaResource&)resource receivedResponse:(const Resour
ASSERT_UNUSED(resource, &resource == _resource);
ASSERT(isMainThread());
[self.session task:self didReceiveCORSAccessCheckResult:resource.didPassAccessControlCheck()];
[self.session updateHasSingleSecurityOrigin:SecurityOrigin::create(response.url())];
self.countOfBytesExpectedToReceive = response.expectedContentLength();
[self _setDefersLoading:YES];
RetainPtr<NSURLResponse> strongResponse { response.nsURLResponse() };
@@ -608,6 +627,8 @@ - (void)resource:(PlatformMediaResource&)resource receivedRedirect:(const Resour
// current request during responseReceieved: to work around a CoreMedia bug.
if (response.httpStatusCode() != 302 && response.httpStatusCode() != 307)
self.currentRequest = [NSURLRequest requestWithURL:request.url()];

[self.session updateHasSingleSecurityOrigin:SecurityOrigin::create(request.url())];
}

- (void)_resource:(PlatformMediaResource&)resource loadFinishedWithError:(NSError *)error

0 comments on commit 35bacb5

Please sign in to comment.