Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(890)

Unified Diff: LayoutTests/http/tests/security/javascriptURL/javascriptURL-execution-context-frame-location-htmldom.html

Issue 22985006: Throw an exception when denying access to 'Frame's 'location' setter. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | LayoutTests/http/tests/security/javascriptURL/javascriptURL-execution-context-frame-location-htmldom-expected.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: LayoutTests/http/tests/security/javascriptURL/javascriptURL-execution-context-frame-location-htmldom.html
diff --git a/LayoutTests/http/tests/security/javascriptURL/javascriptURL-execution-context-frame-location-htmldom.html b/LayoutTests/http/tests/security/javascriptURL/javascriptURL-execution-context-frame-location-htmldom.html
index 1ee1d7e1a138fec41e719aab869696c58fbca264..8448cb6fa1fc694398772db53e0df07e9f42b0f0 100644
--- a/LayoutTests/http/tests/security/javascriptURL/javascriptURL-execution-context-frame-location-htmldom.html
+++ b/LayoutTests/http/tests/security/javascriptURL/javascriptURL-execution-context-frame-location-htmldom.html
@@ -1,39 +1,38 @@
<html>
<head>
<script>
- window.onload = function()
- {
- if (window.testRunner) {
- testRunner.dumpAsText();
- testRunner.dumpChildFramesAsText();
- testRunner.waitUntilDone();
- }
-
- if (window.testRunner) {
- setTimeout(pollForTest, 1);
- } else {
- alert("This test requires it be run in DRT.");
- }
+ if (window.testRunner) {
+ testRunner.dumpAsText();
+ testRunner.dumpChildFramesAsText();
+ testRunner.waitUntilDone();
}
- pollForTest = function()
- {
- if (!testRunner.globalFlag) {
- setTimeout(pollForTest, 1);
- return;
- }
+ window.addEventListener('message', function() {
runTest();
- testRunner.notifyDone();
+ if (window.testRunner)
+ testRunner.notifyDone();
+ });
+
+ setFrameLocation = function(url) {
+ var frame = document.getElementById('aFrame');
+ var jsErrorMessage = 'Blocked a frame with origin "http://127.0.0.1:8000" from accessing a cross-origin frame.';
+ try {
+ frame.location = url;
+ } catch (e) {
+ console.log("Caught exception while setting frame's location to '" + url + "'. '" + e + "'.");
+ if (e.message == jsErrorMessage)
+ console.log("PASS: Exception was '" + e.message + "'.");
+ else
+ console.log("FAIL: Exception should have been '" + jsErrorMessage + "', was '" + e.message + "'.");
+ }
}
- runTest = function()
- {
- var frame = document.getElementById('aFrame');
- frame.location = 'javascript:"FAIL: this should not have been loaded."';
- frame.location = ' javascript:"FAIL: this should not have been loaded."';
- frame.location = 'java\0script:"FAIL: this should not have been loaded."';
- frame.location = 'javascript\t:"FAIL: this should not have been loaded."';
- frame.location = 'javascript\1:"FAIL: this should not have been loaded."';
+ function runTest() {
+ setFrameLocation('javascript:"FAIL: this should not have been loaded."');
+ setFrameLocation(' javascript:"FAIL: this should not have been loaded."');
+ setFrameLocation('java\0script:"FAIL: this should not have been loaded."');
+ setFrameLocation('javascript\t:"FAIL: this should not have been loaded."');
+ setFrameLocation('javascript\1:"FAIL: this should not have been loaded."');
}
</script>
</head>
« no previous file with comments | « no previous file | LayoutTests/http/tests/security/javascriptURL/javascriptURL-execution-context-frame-location-htmldom-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698