Commit f01d2537 authored by yoav@yoav.ws's avatar yoav@yoav.ws

Aligned srcset mixedContent blocking to the spec

Previous implementation did not block mixed content when the srcset attribute was empty.
This CL fixes that.

BUG=402792

Review URL: https://codereview.chromium.org/467533002

git-svn-id: svn://svn.chromium.org/blink/trunk@180059 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 05ea6651
CONSOLE WARNING: line 2: The page at 'https://127.0.0.1:8443/security/mixedContent/resources/frame-with-insecure-empty-srcset.html' was loaded over HTTPS, but ran insecure content from 'http://127.0.0.1:8080/security/resources/compass.jpg': this content should also be loaded over HTTPS.
This test opens a window that loads an insecure image with a srcset attribute.
<html>
<body>
<script>
if (window.testRunner) {
testRunner.waitUntilDone();
testRunner.dumpAsText();
testRunner.setCanOpenWindows();
testRunner.setCloseRemainingWindowsWhenComplete(true);
testRunner.overridePreference("WebKitAllowDisplayingInsecureContent", false);
}
window.addEventListener("message", function (e) {
if (window.testRunner)
testRunner.notifyDone();
}, false);
</script>
<p>This test opens a window that loads an insecure image with a srcset attribute.</p>
<script>
window.open("https://127.0.0.1:8443/security/mixedContent/resources/frame-with-insecure-empty-srcset.html");
</script>
</body>
</html>
<img src="http://127.0.0.1:8080/security/resources/compass.jpg"
srcset>
<script>
window.onload = function() {
if (window.opener)
window.opener.postMessage('done', '*');
};
</script>
...@@ -242,7 +242,7 @@ void ImageLoader::doUpdateFromElement(BypassMainWorldBehavior bypassBehavior, Up ...@@ -242,7 +242,7 @@ void ImageLoader::doUpdateFromElement(BypassMainWorldBehavior bypassBehavior, Up
// Unlike raw <img>, we block mixed content inside of <picture> or <img srcset>. // Unlike raw <img>, we block mixed content inside of <picture> or <img srcset>.
ResourceLoaderOptions resourceLoaderOptions = ResourceFetcher::defaultResourceOptions(); ResourceLoaderOptions resourceLoaderOptions = ResourceFetcher::defaultResourceOptions();
ResourceRequest resourceRequest(url); ResourceRequest resourceRequest(url);
if (isHTMLPictureElement(element()->parentNode()) || !element()->fastGetAttribute(HTMLNames::srcsetAttr).isEmpty()) { if (isHTMLPictureElement(element()->parentNode()) || !element()->fastGetAttribute(HTMLNames::srcsetAttr).isNull()) {
resourceLoaderOptions.mixedContentBlockingTreatment = TreatAsActiveContent; resourceLoaderOptions.mixedContentBlockingTreatment = TreatAsActiveContent;
resourceRequest.setRequestContext(WebURLRequest::RequestContextImageSet); resourceRequest.setRequestContext(WebURLRequest::RequestContextImageSet);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment