Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
http/tests/security/frame-loading-via-document-write-async-delegates.…
…html fails with async delegates https://bugs.webkit.org/show_bug.cgi?id=183460 Reviewed by Alex Christensen. The test has 3 frames which all initially load "about:blank". Then using document.write(), it inserts HTML in each frame. Frame 1: body has an onload event handler, which calls JS is click an anchor link to navigate the frame. Frame 2: body has an onload event handler to do some logging Frame 3: body has an onload event handler and finishes the test (calls testRunner.notifyDone()) The issue is that with asynchronous policy delegates, the first frame may not have navigated yet by the time the third frame is loaded. Indeed, the onload event of the first frame merely clicks am anchor link which will trigger a navigation policy check and then later navigate. To make the test more robust, we now count the number of loads and call testRunner.notifyDone() when we've reached the expected number of loads. * http/tests/security/frame-loading-via-document-write-async-delegates-expected.txt: Added. * http/tests/security/frame-loading-via-document-write-async-delegates.html: Copied from LayoutTests/http/tests/security/frame-loading-via-document-write.html. * http/tests/security/frame-loading-via-document-write.html: * http/tests/security/resources/frame-loading-via-document-write.js: Canonical link: https://commits.webkit.org/199170@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@229468 268f45cc-cd09-0410-ab3c-d52691b4dbfc
- Loading branch information
Showing
with
141 additions
and 12 deletions.
- +25 −0 LayoutTests/ChangeLog
- +22 −0 LayoutTests/http/tests/security/frame-loading-via-document-write-async-delegates-expected.txt
- +82 −0 LayoutTests/http/tests/security/frame-loading-via-document-write-async-delegates.html
- +12 −4 LayoutTests/http/tests/security/frame-loading-via-document-write.html
- +0 −8 LayoutTests/http/tests/security/resources/frame-loading-via-document-write.js
There are no files selected for viewing
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
@@ -0,0 +1,22 @@ | ||
CONSOLE MESSAGE: line 1: Not allowed to load local resource: abe.png | ||
|
||
|
||
-------- | ||
Frame: 'topRow' | ||
-------- | ||
This page was successfully loaded. | ||
My protocol is http: | ||
My referrer is blank | ||
|
||
|
||
-------- | ||
Frame: 'middleRow' | ||
-------- | ||
Image NOT loaded. | ||
|
||
|
||
-------- | ||
Frame: 'bottomRow' | ||
-------- | ||
Image loaded. | ||
|
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
@@ -0,0 +1,82 @@ | ||
<html> | ||
<head> | ||
<title></title> | ||
|
||
<script language="JavaScript"> | ||
|
||
const expectedLoadCount = 7; | ||
let loadCount = 0; | ||
function finishTestIfLastLoad() | ||
{ | ||
if (++loadCount == expectedLoadCount && window.testRunner) | ||
testRunner.notifyDone(); | ||
} | ||
|
||
function buildFrameset() | ||
{ | ||
if (window.testRunner) { | ||
testRunner.waitUntilDone(); | ||
testRunner.dumpAsText(); | ||
testRunner.dumpChildFramesAsText(); | ||
if (testRunner.setShouldDecideNavigationPolicyAfterDelay) | ||
testRunner.setShouldDecideNavigationPolicyAfterDelay(true); | ||
} | ||
|
||
var outHTML="<frameset rows=\"33%, 33%, 33%\">"+ | ||
"<frame src=\"\" onload=\"finishTestIfLastLoad()\" name=\"topRow\">"+ | ||
"<frame src=\"\" onload=\"finishTestIfLastLoad()\" name=\"middleRow\">"+ | ||
"<frame src=\"\" onload=\"finishTestIfLastLoad()\" name=\"bottomRow\">"+ | ||
"</frameset>"; | ||
|
||
document.open("text/html","replace"); | ||
document.write(outHTML); | ||
document.close(); | ||
|
||
outHTML = "<html><head><scr" + "ipt language=\"JavaScript\" src=\"resources/frame-loading-via-document-write.js\">"+ | ||
"</scr" + "ipt></head><body onLoad=\"clickAnchor()\"><table><tr><td>"+ | ||
"<a href=\"resources/success.html\" target=\"topRow\" id=\"anchorLink\">Click me. If nothing loads above we have a problem.</a>"+ | ||
"</td></tr></table></body></html>"; | ||
|
||
frames['topRow'].document.open("text/html","replace"); | ||
frames['topRow'].document.charset=document.charset; | ||
frames['topRow'].document.write(outHTML); | ||
frames['topRow'].document.close(); | ||
|
||
var localImageLocation = "file:///tmp/LayoutTests/fast/dom/resources/abe.png"; | ||
if (window.testRunner) | ||
localImageLocation = testRunner.pathToLocalResource(localImageLocation); | ||
|
||
outHTML = "<html><head><scr" + "ipt language=\"JavaScript\" src=\"resources/frame-loading-via-document-write.js\">"+ | ||
"</scr" + "ipt></head><body onLoad=\"didImageLoad()\"><table><tr><td>"+ | ||
"<div id=\"result\"></div>"+ | ||
"<img src=\"" + localImageLocation + "\" id=\"myImg\">"+ | ||
"</td></tr></table></body></html>"; | ||
|
||
frames['middleRow'].document.open("text/html","replace"); | ||
frames['middleRow'].document.charset=document.charset; | ||
frames['middleRow'].document.write(outHTML); | ||
frames['middleRow'].document.close(); | ||
|
||
outHTML = "<html><head><scr" + "ipt language=\"JavaScript\" src=\"resources/frame-loading-via-document-write.js\">"+ | ||
"</scr" + "ipt></head><body onLoad=\"didImageLoad()\"><table><tr><td>"+ | ||
"<div id=\"result\"></div>"+ | ||
"<img src=\"/resources/abe.png\" id=\"myImg\">"+ | ||
"</td></tr></table></body></html>"; | ||
|
||
frames['bottomRow'].document.open("text/html","replace"); | ||
frames['bottomRow'].document.charset=document.charset; | ||
frames['bottomRow'].document.write(outHTML); | ||
frames['bottomRow'].document.close(); | ||
} | ||
|
||
buildFrameset(); | ||
|
||
</script> | ||
</head> | ||
|
||
<body> | ||
<p>JavaScript FAILED! you should not see this.</p> | ||
</body> | ||
|
||
</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
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
@@ -17,11 +17,3 @@ function didImageLoad() | ||
} | ||
} | ||
|
||