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> |