RESOLVED FIXED 152489
Allow JavaScript to iterate over plugins for local SecurityOrigins
https://bugs.webkit.org/show_bug.cgi?id=152489
Summary Allow JavaScript to iterate over plugins for local SecurityOrigins
Brent Fulgham
Reported 2015-12-21 12:43:27 PST
This bug refines Bug 151783 slightly based on Darin's suggestion: "I’d really prefer that this security check be done with SecurityOrigin function rather than a direct call to isLocalFile.". This patch revises the code slightly to do just that.
Attachments
Patch (1.56 KB, patch)
2015-12-21 12:47 PST, Brent Fulgham
no flags
Patch (4.82 KB, patch)
2015-12-22 10:05 PST, Brent Fulgham
no flags
Patch (4.36 KB, patch)
2015-12-22 10:29 PST, Brent Fulgham
ap: review+
Brent Fulgham
Comment 1 2015-12-21 12:47:15 PST
Alexey Proskuryakov
Comment 2 2015-12-21 14:06:36 PST
Comment on attachment 267761 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=267761&action=review > Source/WebCore/page/Page.cpp:532 > + DocumentLoader* documentLoader = mainFrame().loader().documentLoader(); > + if (!documentLoader) > + return false; There wasn't a null check for documentLoader before, but there is one now. Can a regression test be added for this change? > Source/WebCore/page/Page.cpp:534 > + RefPtr<SecurityOrigin> origin(SecurityOrigin::create(documentLoader->url())); SecurityOrigin::create returns a Ref, so please don't make a RefPtr out of it. I think that this is the right way to write this: Ref<SecurityOrigin> origin = SecurityOrigin::create(documentLoader->url()); But more importantly, I think that we should use the actual security origin for the document, not a one reconstructed from its URL. I don't know of an observable difference, but calling securityOrigin() on the document feels like a better thing to do.
Brent Fulgham
Comment 3 2015-12-22 09:57:06 PST
(In reply to comment #2) > Comment on attachment 267761 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=267761&action=review > > > Source/WebCore/page/Page.cpp:532 > > + DocumentLoader* documentLoader = mainFrame().loader().documentLoader(); > > + if (!documentLoader) > > + return false; > > There wasn't a null check for documentLoader before, but there is one now. > Can a regression test be added for this change? After looking at some of the other uses of documentLoader here (and elsewhere), I noticed that many of them are doing null checks, so I added one here. I'm not sure how to create a test that hits this code with a nullptr documentLoader. > > Source/WebCore/page/Page.cpp:534 > > + RefPtr<SecurityOrigin> origin(SecurityOrigin::create(documentLoader->url())); > > SecurityOrigin::create returns a Ref, so please don't make a RefPtr out of > it. I think that this is the right way to write this: > > Ref<SecurityOrigin> origin = SecurityOrigin::create(documentLoader->url()); Done. > But more importantly, I think that we should use the actual security origin > for the document, not a one reconstructed from its URL. I don't know of an > observable difference, but calling securityOrigin() on the document feels > like a better thing to do. I can certainly do that. However, it looks like securityOrigin() is not guaranteed to return a value, so I think we should use the securityOrigin if it exists, otherwise we have to generate one from the URL.
Brent Fulgham
Comment 4 2015-12-22 10:05:20 PST
Alexey Proskuryakov
Comment 5 2015-12-22 10:08:08 PST
Comment on attachment 267790 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=267790&action=review > Source/WebKit2/WebProcess/WebCoreSupport/WebPlatformStrategies.cpp:197 > + } else if (DocumentLoader* documentLoader = page->mainFrame().loader().documentLoader()) { Do we use this idiom anywhere else? I would expect that if document->securityOrigin() returns null, then there isn't a security origin for us to use, so we should not fall back to the URL.
Brent Fulgham
Comment 6 2015-12-22 10:12:07 PST
(In reply to comment #5) > Comment on attachment 267790 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=267790&action=review > > > Source/WebKit2/WebProcess/WebCoreSupport/WebPlatformStrategies.cpp:197 > > + } else if (DocumentLoader* documentLoader = page->mainFrame().loader().documentLoader()) { > > Do we use this idiom anywhere else? I would expect that if > document->securityOrigin() returns null, then there isn't a security origin > for us to use, so we should not fall back to the URL. I have to admit I cannot find a single place where we don't just trust the return value of document()->securityOrigin(). It must be 'guaranteed' to exist. I'll remove that fallback case.
Brent Fulgham
Comment 7 2015-12-22 10:29:55 PST
Brent Fulgham
Comment 8 2015-12-22 11:38:12 PST
Note You need to log in before you can comment on or make changes to this bug.