my first test
authorbhill@L-SJN-00530327.corp.ebay.com
Tue, 20 Dec 2011 12:22:29 -0600
changeset 19 98421000f64c
parent 18 79828772335d
child 20 e11a5fd84f2b
my first test
tests/csp/submitted/bhill2/csp-self.php
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/csp/submitted/bhill2/csp-self.php	Tue Dec 20 12:22:29 2011 -0600
@@ -0,0 +1,43 @@
+<?php
+header("X-Content-Security-Policy: allow 'self'");
+?>
+<!doctype html>
+<html>
+  <head>
+    <title>XMLHttpRequest: abort() after send()</title>
+    <script src="/resources/testharness.js"></script>
+  </head>
+  <body>
+    <div id="log"></div>
+    <script>
+      var test = async_test()
+      test.step(function() {
+        var client = new XMLHttpRequest(),
+            control_flag = false,
+            result = [],
+            expected = [1, 1, 4] // open() -> 1, send() -> 1, abort() -> 4
+        client.onreadystatechange = function() {
+          test.step(function() {
+            result.push(client.readyState)
+            if(client.readyState == 4) {
+              control_flag = true
+              assert_equals(client.responseXML, null)
+              assert_equals(client.responseText, "")
+              assert_equals(client.status, 0)
+              assert_equals(client.statusText, "")
+              assert_equals(client.getAllResponseHeaders(), "")
+            }
+          })
+        }
+        client.open("GET", "../resources/delay.php?ms=2000", true)
+        client.send(null)
+        client.abort()
+        assert_true(control_flag)
+        assert_equals(client.readyState, 0)
+        assert_array_equals(result, expected)
+        test.done()
+      })
+    </script>
+  </body>
+</html>
+