-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CSP: Check <param> element values against the document's CSP before l…
…oading. We ought to take account of the 'param' element parsing behavior that happens in 'HTMLObjectElement'. This patch moves the pluginIsLoadable check to make that happen. To avoid 'setTimeout' in the test, and to align with the spec[1], this patch also starts dispatching an 'error' event on load failure for 'object' elements. [1]: #4.6 ("If the load failed...") of http://www.whatwg.org/specs/web-apps/current-work/multipage/the-iframe-element.html#the-object-element BUG=320796 [email protected],[email protected] Review URL: https://codereview.chromium.org/76303002 git-svn-id: svn://svn.chromium.org/blink/trunk@164952 bbb929c8-8fbe-4397-9dbb-9b2b20218538
- Loading branch information
1 parent
a1f451a
commit b0e15a6
Showing
13 changed files
with
125 additions
and
14 deletions.
There are no files selected for viewing
5 changes: 0 additions & 5 deletions
5
...utTests/http/tests/security/contentSecurityPolicy/1.1/plugintypes-notype-url-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,3 @@ | ||
CONSOLE ERROR: Refused to load 'http://127.0.0.1:8000/plugins/resources/mock-plugin.pl' (MIME type '') because it violates the following Content Security Policy Directive: 'plugin-types application/x-invalid-type'. When enforcing the 'plugin-types' directive, the plugin's media type must be explicitly declared with a 'type' attribute on the containing element (e.g. '<object type="[TYPE GOES HERE]" ...>'). | ||
|
||
Given a `plugin-types` directive, plugins have to declare a type explicitly. No declared type, no load. This test passes if there's a console message above. | ||
|
||
-------- | ||
Frame: '<!--framePath //<!--frame0-->-->' | ||
-------- | ||
|
4 changes: 4 additions & 0 deletions
4
...ests/http/tests/security/contentSecurityPolicy/object-src-param-code-blocked-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
CONSOLE ERROR: Refused to load plugin data from 'http://127.0.0.1:8080/plugins/resources/mock-plugin.pl?code' because it violates the following Content Security Policy directive: "object-src http://localhost:8080". | ||
|
||
CONSOLE MESSAGE: line 16: PASS: Error occurred, so load was correctly blocked. | ||
This test passes if there is a console message saying the plugin was blocked. |
13 changes: 13 additions & 0 deletions
13
LayoutTests/http/tests/security/contentSecurityPolicy/object-src-param-code-blocked.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<script src="resources/object-src-param.js"></script> | ||
<meta http-equiv="Content-Security-Policy" content="object-src http://localhost:8080"> | ||
</head> | ||
<body> | ||
This test passes if there is a console message saying the plugin was blocked. | ||
<script> | ||
appendObjectElement('code'); | ||
</script> | ||
</body> | ||
</html> |
4 changes: 4 additions & 0 deletions
4
...sts/http/tests/security/contentSecurityPolicy/object-src-param-movie-blocked-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
CONSOLE ERROR: Refused to load plugin data from 'http://127.0.0.1:8080/plugins/resources/mock-plugin.pl?movie' because it violates the following Content Security Policy directive: "object-src http://localhost:8080". | ||
|
||
CONSOLE MESSAGE: line 16: PASS: Error occurred, so load was correctly blocked. | ||
This test passes if there is a console message saying the plugin was blocked. |
13 changes: 13 additions & 0 deletions
13
LayoutTests/http/tests/security/contentSecurityPolicy/object-src-param-movie-blocked.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<script src="resources/object-src-param.js"></script> | ||
<meta http-equiv="Content-Security-Policy" content="object-src http://localhost:8080"> | ||
</head> | ||
<body> | ||
This test passes if there is a console message saying the plugin was blocked. | ||
<script> | ||
appendObjectElement('movie'); | ||
</script> | ||
</body> | ||
</html> |
4 changes: 4 additions & 0 deletions
4
...Tests/http/tests/security/contentSecurityPolicy/object-src-param-src-blocked-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
CONSOLE ERROR: Refused to load plugin data from 'http://127.0.0.1:8080/plugins/resources/mock-plugin.pl?src' because it violates the following Content Security Policy directive: "object-src http://localhost:8080". | ||
|
||
CONSOLE MESSAGE: line 16: PASS: Error occurred, so load was correctly blocked. | ||
This test passes if there is a console message saying the plugin was blocked. |
13 changes: 13 additions & 0 deletions
13
LayoutTests/http/tests/security/contentSecurityPolicy/object-src-param-src-blocked.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<script src="resources/object-src-param.js"></script> | ||
<meta http-equiv="Content-Security-Policy" content="object-src http://localhost:8080"> | ||
</head> | ||
<body> | ||
This test passes if there is a console message saying the plugin was blocked. | ||
<script> | ||
appendObjectElement('src'); | ||
</script> | ||
</body> | ||
</html> |
4 changes: 4 additions & 0 deletions
4
...Tests/http/tests/security/contentSecurityPolicy/object-src-param-url-blocked-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
CONSOLE ERROR: Refused to load plugin data from 'http://127.0.0.1:8080/plugins/resources/mock-plugin.pl?url' because it violates the following Content Security Policy directive: "object-src http://localhost:8080". | ||
|
||
CONSOLE MESSAGE: line 16: PASS: Error occurred, so load was correctly blocked. | ||
This test passes if there is a console message saying the plugin was blocked. |
13 changes: 13 additions & 0 deletions
13
LayoutTests/http/tests/security/contentSecurityPolicy/object-src-param-url-blocked.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<script src="resources/object-src-param.js"></script> | ||
<meta http-equiv="Content-Security-Policy" content="object-src http://localhost:8080"> | ||
</head> | ||
<body> | ||
This test passes if there is a console message saying the plugin was blocked. | ||
<script> | ||
appendObjectElement('url'); | ||
</script> | ||
</body> | ||
</html> |
29 changes: 29 additions & 0 deletions
29
LayoutTests/http/tests/security/contentSecurityPolicy/resources/object-src-param.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
if (window.testRunner) { | ||
testRunner.dumpAsText(); | ||
testRunner.waitUntilDone(); | ||
} | ||
|
||
function appendObjectElement(type) { | ||
window.onload = function () { | ||
var o = document.createElement('object'); | ||
o.setAttribute('type', 'application/x-webkit-test-netscape'); | ||
o.addEventListener('load', function () { | ||
console.log('FAIL: The object should have been blocked.'); | ||
if (window.testRunner) | ||
testRunner.notifyDone(); | ||
}); | ||
o.addEventListener('error', function () { | ||
console.log('PASS: Error occurred, so load was correctly blocked.'); | ||
if (window.testRunner) | ||
testRunner.notifyDone(); | ||
}); | ||
|
||
var p = document.createElement('param'); | ||
p.setAttribute('value', 'http://127.0.0.1:8080/plugins/resources/mock-plugin.pl?' + type); | ||
p.setAttribute('name', type); | ||
|
||
o.appendChild(p); | ||
|
||
document.body.appendChild(o); | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters