<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[185296] trunk/LayoutTests</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/185296">185296</a></dd>
<dt>Author</dt> <dd>ap@apple.com</dd>
<dt>Date</dt> <dd>2015-06-06 17:09:27 -0700 (Sat, 06 Jun 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>Clean up tests for blocking mixed content
https://bugs.webkit.org/show_bug.cgi?id=145718

Reviewed by Darin Adler.

Stop using timeouts, which were making the tests flaky.

* http/tests/xmlhttprequest/access-control-response-with-body.html: This wasn't even
a mixed content test, but the file was reused in one. I now made a separate helper
document, so this is just a regular test now, not another test's resource.

* http/tests/security/mixedContent/redirect-http-to-https-iframe-in-main-frame.html:
* http/tests/security/mixedContent/redirect-https-to-http-iframe-in-main-frame.html:
* http/tests/security/mixedContent/resources/frame-with-insecure-frame.html:
* http/tests/security/mixedContent/resources/frame-with-redirect-http-to-https-frame.html:
* http/tests/security/mixedContent/resources/frame-with-redirect-https-to-http-frame.html:
Refactored to not depend on timeouts.

* http/tests/security/mixedContent/insecure-xhr-in-main-frame-expected.txt:
* http/tests/security/mixedContent/insecure-xhr-in-main-frame.html:
* http/tests/security/mixedContent/resources/insecure-xhr-in-main-frame-window.html: Added.
This test still needs a timeout, because of a WebKit bug. I just made it much longer.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestshttptestssecuritymixedContentinsecurexhrinmainframeexpectedtxt">trunk/LayoutTests/http/tests/security/mixedContent/insecure-xhr-in-main-frame-expected.txt</a></li>
<li><a href="#trunkLayoutTestshttptestssecuritymixedContentinsecurexhrinmainframehtml">trunk/LayoutTests/http/tests/security/mixedContent/insecure-xhr-in-main-frame.html</a></li>
<li><a href="#trunkLayoutTestshttptestssecuritymixedContentredirecthttptohttpsiframeinmainframehtml">trunk/LayoutTests/http/tests/security/mixedContent/redirect-http-to-https-iframe-in-main-frame.html</a></li>
<li><a href="#trunkLayoutTestshttptestssecuritymixedContentredirecthttpstohttpiframeinmainframehtml">trunk/LayoutTests/http/tests/security/mixedContent/redirect-https-to-http-iframe-in-main-frame.html</a></li>
<li><a href="#trunkLayoutTestshttptestssecuritymixedContentresourcesframewithinsecureframehtml">trunk/LayoutTests/http/tests/security/mixedContent/resources/frame-with-insecure-frame.html</a></li>
<li><a href="#trunkLayoutTestshttptestssecuritymixedContentresourcesframewithredirecthttptohttpsframehtml">trunk/LayoutTests/http/tests/security/mixedContent/resources/frame-with-redirect-http-to-https-frame.html</a></li>
<li><a href="#trunkLayoutTestshttptestssecuritymixedContentresourcesframewithredirecthttpstohttpframehtml">trunk/LayoutTests/http/tests/security/mixedContent/resources/frame-with-redirect-https-to-http-frame.html</a></li>
<li><a href="#trunkLayoutTestshttptestsxmlhttprequestaccesscontrolresponsewithbodyhtml">trunk/LayoutTests/http/tests/xmlhttprequest/access-control-response-with-body.html</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestshttptestssecuritymixedContentresourcesinsecurexhrinmainframewindowhtml">trunk/LayoutTests/http/tests/security/mixedContent/resources/insecure-xhr-in-main-frame-window.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (185295 => 185296)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2015-06-06 22:55:41 UTC (rev 185295)
+++ trunk/LayoutTests/ChangeLog        2015-06-07 00:09:27 UTC (rev 185296)
</span><span class="lines">@@ -1,3 +1,28 @@
</span><ins>+2015-06-06  Alexey Proskuryakov  &lt;ap@apple.com&gt;
+
+        Clean up tests for blocking mixed content
+        https://bugs.webkit.org/show_bug.cgi?id=145718
+
+        Reviewed by Darin Adler.
+
+        Stop using timeouts, which were making the tests flaky.
+
+        * http/tests/xmlhttprequest/access-control-response-with-body.html: This wasn't even
+        a mixed content test, but the file was reused in one. I now made a separate helper
+        document, so this is just a regular test now, not another test's resource.
+
+        * http/tests/security/mixedContent/redirect-http-to-https-iframe-in-main-frame.html:
+        * http/tests/security/mixedContent/redirect-https-to-http-iframe-in-main-frame.html:
+        * http/tests/security/mixedContent/resources/frame-with-insecure-frame.html:
+        * http/tests/security/mixedContent/resources/frame-with-redirect-http-to-https-frame.html:
+        * http/tests/security/mixedContent/resources/frame-with-redirect-https-to-http-frame.html:
+        Refactored to not depend on timeouts.
+
+        * http/tests/security/mixedContent/insecure-xhr-in-main-frame-expected.txt:
+        * http/tests/security/mixedContent/insecure-xhr-in-main-frame.html:
+        * http/tests/security/mixedContent/resources/insecure-xhr-in-main-frame-window.html: Added.
+        This test still needs a timeout, because of a WebKit bug. I just made it much longer.
+
</ins><span class="cx"> 2015-06-06  Mark Lam  &lt;mark.lam@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Returned Exception* values need to be initialized to nullptr when no exceptions are thrown.
</span></span></pre></div>
<a id="trunkLayoutTestshttptestssecuritymixedContentinsecurexhrinmainframeexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/http/tests/security/mixedContent/insecure-xhr-in-main-frame-expected.txt (185295 => 185296)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/security/mixedContent/insecure-xhr-in-main-frame-expected.txt        2015-06-06 22:55:41 UTC (rev 185295)
+++ trunk/LayoutTests/http/tests/security/mixedContent/insecure-xhr-in-main-frame-expected.txt        2015-06-07 00:09:27 UTC (rev 185296)
</span><span class="lines">@@ -1,3 +1,3 @@
</span><del>-CONSOLE MESSAGE: line 26: [blocked] The page at https://127.0.0.1:8443/xmlhttprequest/access-control-response-with-body.html was not allowed to display insecure content from http://localhost:8000/xmlhttprequest/resources/access-control-allow-with-body.php.
</del><ins>+CONSOLE MESSAGE: line 28: [blocked] The page at https://127.0.0.1:8443/security/mixedContent/resources/insecure-xhr-in-main-frame-window.html was not allowed to display insecure content from http://127.0.0.1:8000/.
</ins><span class="cx"> 
</span><span class="cx"> This test opens a HTTPS window that loads insecure data via XHR. We should trigger a mixed content callback because the main frame in the window is HTTPS but now has insecure data.
</span></span></pre></div>
<a id="trunkLayoutTestshttptestssecuritymixedContentinsecurexhrinmainframehtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/http/tests/security/mixedContent/insecure-xhr-in-main-frame.html (185295 => 185296)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/security/mixedContent/insecure-xhr-in-main-frame.html        2015-06-06 22:55:41 UTC (rev 185295)
+++ trunk/LayoutTests/http/tests/security/mixedContent/insecure-xhr-in-main-frame.html        2015-06-07 00:09:27 UTC (rev 185296)
</span><span class="lines">@@ -8,20 +8,13 @@
</span><span class="cx">     testRunner.setCloseRemainingWindowsWhenComplete(true);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-window.addEventListener(&quot;message&quot;, function (e) {
-    if (window.testRunner)
-        testRunner.notifyDone();
-    if (e.data == &quot;done&quot;)
-            throw &quot;Should not load this&quot;
-}, false);
-
</del><span class="cx"> &lt;/script&gt;
</span><span class="cx"> &lt;p&gt;This test opens a HTTPS window that loads insecure data via XHR.  We should
</span><span class="cx"> trigger a mixed content callback because the main frame in the window is HTTPS but
</span><span class="cx"> now has insecure data.&lt;/p&gt;
</span><span class="cx"> &lt;script&gt;
</span><span class="cx"> onload = function() {
</span><del>-    window.open(&quot;https://127.0.0.1:8443/xmlhttprequest/access-control-response-with-body.html&quot;);
</del><ins>+    window.open(&quot;https://127.0.0.1:8443/security/mixedContent/resources/insecure-xhr-in-main-frame-window.html&quot;);
</ins><span class="cx"> }
</span><span class="cx"> &lt;/script&gt;
</span><span class="cx"> &lt;/body&gt;
</span></span></pre></div>
<a id="trunkLayoutTestshttptestssecuritymixedContentredirecthttptohttpsiframeinmainframehtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/http/tests/security/mixedContent/redirect-http-to-https-iframe-in-main-frame.html (185295 => 185296)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/security/mixedContent/redirect-http-to-https-iframe-in-main-frame.html        2015-06-06 22:55:41 UTC (rev 185295)
+++ trunk/LayoutTests/http/tests/security/mixedContent/redirect-http-to-https-iframe-in-main-frame.html        2015-06-07 00:09:27 UTC (rev 185296)
</span><span class="lines">@@ -10,10 +10,10 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> window.addEventListener(&quot;message&quot;, function (e) {
</span><del>-  if (window.testRunner)
-      testRunner.notifyDone();
-        if (e.data == &quot;done&quot;)
-            throw &quot;should not have loaded insecure content&quot;
</del><ins>+    if (e.data == &quot;done&quot;)
+        alert(&quot;should not have loaded insecure content&quot;);
+    if (window.testRunner)
+        testRunner.notifyDone();
</ins><span class="cx"> }, false);
</span><span class="cx"> 
</span><span class="cx"> &lt;/script&gt;
</span></span></pre></div>
<a id="trunkLayoutTestshttptestssecuritymixedContentredirecthttpstohttpiframeinmainframehtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/http/tests/security/mixedContent/redirect-https-to-http-iframe-in-main-frame.html (185295 => 185296)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/security/mixedContent/redirect-https-to-http-iframe-in-main-frame.html        2015-06-06 22:55:41 UTC (rev 185295)
+++ trunk/LayoutTests/http/tests/security/mixedContent/redirect-https-to-http-iframe-in-main-frame.html        2015-06-07 00:09:27 UTC (rev 185296)
</span><span class="lines">@@ -10,10 +10,10 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> window.addEventListener(&quot;message&quot;, function (e) {
</span><ins>+        if (e.data == &quot;done&quot;)
+            alert(&quot;should not have loaded insecure content&quot;);
</ins><span class="cx">         if (window.testRunner)
</span><span class="cx">                 testRunner.notifyDone()
</span><del>-        if (e.data == &quot;done&quot;)
-            throw &quot;should not have loaded insecure content&quot;
</del><span class="cx"> }, false);
</span><span class="cx"> 
</span><span class="cx"> &lt;/script&gt;
</span></span></pre></div>
<a id="trunkLayoutTestshttptestssecuritymixedContentresourcesframewithinsecureframehtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/http/tests/security/mixedContent/resources/frame-with-insecure-frame.html (185295 => 185296)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/security/mixedContent/resources/frame-with-insecure-frame.html        2015-06-06 22:55:41 UTC (rev 185295)
+++ trunk/LayoutTests/http/tests/security/mixedContent/resources/frame-with-insecure-frame.html        2015-06-07 00:09:27 UTC (rev 185296)
</span><span class="lines">@@ -1,12 +1,11 @@
</span><span class="cx"> &lt;script&gt;
</span><del>-function frameLoaded() {
-  if (window.opener)
-    window.opener.postMessage('done', '*');
</del><ins>+var frameDidLoad = false;
+
+onload = function()
+{
+    if (window.opener)
+        window.opener.postMessage(frameDidLoad ? 'done' : 'blocked', '*');
</ins><span class="cx"> }
</span><del>-setTimeout(function(){
-  if (window.opener)
-    window.opener.postMessage('blocked', '*');
-}, 100)
</del><span class="cx"> &lt;/script&gt;
</span><del>-&lt;iframe onload=&quot;frameLoaded()&quot;
</del><ins>+&lt;iframe onload=&quot;frameDidLoad = true&quot;
</ins><span class="cx">         src=&quot;http://127.0.0.1:8080/security/mixedContent/resources/boring.html&quot;&gt;&lt;/iframe&gt;
</span></span></pre></div>
<a id="trunkLayoutTestshttptestssecuritymixedContentresourcesframewithredirecthttptohttpsframehtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/http/tests/security/mixedContent/resources/frame-with-redirect-http-to-https-frame.html (185295 => 185296)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/security/mixedContent/resources/frame-with-redirect-http-to-https-frame.html        2015-06-06 22:55:41 UTC (rev 185295)
+++ trunk/LayoutTests/http/tests/security/mixedContent/resources/frame-with-redirect-http-to-https-frame.html        2015-06-07 00:09:27 UTC (rev 185296)
</span><span class="lines">@@ -1,12 +1,11 @@
</span><span class="cx"> &lt;script&gt;
</span><del>-function frameLoaded() {
-  if (window.opener)
-    window.opener.postMessage('done', '*');
</del><ins>+var frameDidLoad = false;
+
+onload = function()
+{
+    if (window.opener)
+        window.opener.postMessage(frameDidLoad ? 'done' : 'blocked', '*');
</ins><span class="cx"> }
</span><del>-setTimeout(function(){
-  if (window.opener)
-    window.opener.postMessage('blocked', '*');
-}, 100)
</del><span class="cx"> &lt;/script&gt;
</span><del>-&lt;iframe onload=&quot;frameLoaded()&quot; onerror=&quot;frameLoaded()&quot;
</del><ins>+&lt;iframe onload=&quot;window.frameDidLoad = true&quot;
</ins><span class="cx">         src=&quot;http://127.0.0.1:8080/resources/redirect.php?url=https://127.0.0.1:8443/security/mixedContent/resources/boring.html&quot;&gt;&lt;/iframe&gt;
</span></span></pre></div>
<a id="trunkLayoutTestshttptestssecuritymixedContentresourcesframewithredirecthttpstohttpframehtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/http/tests/security/mixedContent/resources/frame-with-redirect-https-to-http-frame.html (185295 => 185296)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/security/mixedContent/resources/frame-with-redirect-https-to-http-frame.html        2015-06-06 22:55:41 UTC (rev 185295)
+++ trunk/LayoutTests/http/tests/security/mixedContent/resources/frame-with-redirect-https-to-http-frame.html        2015-06-07 00:09:27 UTC (rev 185296)
</span><span class="lines">@@ -1,13 +1,12 @@
</span><span class="cx"> &lt;script&gt;
</span><del>-function frameLoaded() {
-  if (window.opener)
-    window.opener.postMessage('done', '*');
</del><ins>+var frameDidLoad = false;
+
+onload = function()
+{
+    if (window.opener)
+        window.opener.postMessage(frameDidLoad ? 'done' : 'blocked', '*');
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-setTimeout(function(){
-  if (window.opener)
-    window.opener.postMessage('blocked', '*');
-}, 100)
</del><span class="cx"> &lt;/script&gt;
</span><del>-&lt;iframe onload=&quot;frameLoaded()&quot; onerror=&quot;frameLoaded()&quot;
</del><ins>+&lt;iframe onload=&quot;window.frameDidLoad = true&quot;
</ins><span class="cx">         src=&quot;https://127.0.0.1:8443/resources/redirect.php?url=http://127.0.0.1:8080/security/mixedContent/resources/boring.html&quot;&gt;&lt;/iframe&gt;
</span></span></pre></div>
<a id="trunkLayoutTestshttptestssecuritymixedContentresourcesinsecurexhrinmainframewindowhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/security/mixedContent/resources/insecure-xhr-in-main-frame-window.html (0 => 185296)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/security/mixedContent/resources/insecure-xhr-in-main-frame-window.html                                (rev 0)
+++ trunk/LayoutTests/http/tests/security/mixedContent/resources/insecure-xhr-in-main-frame-window.html        2015-06-07 00:09:27 UTC (rev 185296)
</span><span class="lines">@@ -0,0 +1,33 @@
</span><ins>+&lt;html&gt;
+&lt;body&gt;
+&lt;script&gt;
+
+window.onload = function() {
+    var xhr = new XMLHttpRequest();
+    xhr.onload = function() {
+        alert(&quot;FAIL: load was not blocked&quot;);
+        if (window.testRunner)
+            testRunner.notifyDone();
+    };
+
+    // When XHR is blocked due to mixed content blocking, it just appears as if the load stalls,
+    // see https://bugs.webkit.org/show_bug.cgi?id=145717.
+    setTimeout(function() {
+        if (window.testRunner)
+            testRunner.notifyDone();
+    }, 2000);
+
+    try {
+        xhr.open(&quot;GET&quot;, &quot;http://127.0.0.1:8000/&quot;);
+    } catch (ex) {
+        // Firefox raises an exception, which is one way to make this detectable.
+        if (window.testRunner)
+            testRunner.notifyDone();
+    }
+
+    xhr.send(null);
+};
+&lt;/script&gt;
+
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestsxmlhttprequestaccesscontrolresponsewithbodyhtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/http/tests/xmlhttprequest/access-control-response-with-body.html (185295 => 185296)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/xmlhttprequest/access-control-response-with-body.html        2015-06-06 22:55:41 UTC (rev 185295)
+++ trunk/LayoutTests/http/tests/xmlhttprequest/access-control-response-with-body.html        2015-06-07 00:09:27 UTC (rev 185296)
</span><span class="lines">@@ -5,31 +5,25 @@
</span><span class="cx"> &lt;div id=result&gt;Running test...&lt;/div&gt;
</span><span class="cx"> &lt;script&gt;
</span><span class="cx"> 
</span><del>-  if (window.testRunner) {
</del><ins>+if (window.testRunner) {
</ins><span class="cx">     testRunner.dumpAsText();
</span><span class="cx">     testRunner.waitUntilDone();
</span><del>-  }
</del><ins>+}
</ins><span class="cx"> 
</span><del>-  window.onload = function() {
-      var xhr = new XMLHttpRequest();
-      xhr.onreadystatechange=function() {
-        if (xhr.readyState==4) {
-          document.getElementById(&quot;result&quot;).innerHTML = (xhr.responseText == &quot;echo&quot;) ? &quot;PASS&quot; : (&quot;FAIL: &quot; + xhr.responseText);
-          if (window.testRunner)
</del><ins>+window.onload = function() {
+    var xhr = new XMLHttpRequest();
+    xhr.onload=function() {
+        document.getElementById(&quot;result&quot;).innerHTML = (xhr.responseText == &quot;echo&quot;) ? &quot;PASS&quot; : (&quot;FAIL: &quot; + xhr.responseText);
+        if (window.testRunner)
</ins><span class="cx">             testRunner.notifyDone();
</span><del>-        }
-       };
</del><ins>+    };
</ins><span class="cx"> 
</span><del>-       xhr.open(&quot;GET&quot;,&quot;http://localhost:8000/xmlhttprequest/resources/access-control-allow-with-body.php&quot;);
-       xhr.setRequestHeader(&quot;Content-type&quot;, &quot;application/x-www-form-urlencoded&quot;);
-       xhr.setRequestHeader(&quot;X-Requested-With&quot;, &quot;XMLHttpRequest&quot;);
-       xhr.send(null);
-       setTimeout(function(){
-          if (window.testRunner)
-              testRunner.notifyDone()
-       }, 100)
-  };
-  
</del><ins>+    xhr.open(&quot;GET&quot;,&quot;http://localhost:8000/xmlhttprequest/resources/access-control-allow-with-body.php&quot;);
+    xhr.setRequestHeader(&quot;Content-type&quot;, &quot;application/x-www-form-urlencoded&quot;);
+    xhr.setRequestHeader(&quot;X-Requested-With&quot;, &quot;XMLHttpRequest&quot;);
+    xhr.send(null);
+};
+
</ins><span class="cx"> &lt;/script&gt;
</span><span class="cx"> 
</span><span class="cx"> &lt;/body&gt;
</span></span></pre>
</div>
</div>

</body>
</html>