Bug 1085060 - update WPTs for XHR sends to also test with workers; r=annevk
authorThomas Wisniewski <twisniewski@mozilla.com>
Wed, 13 Mar 2019 14:40:47 +0000
changeset 521750 01cbcad8bb67a1a761045d8900af7db060a2f965
parent 521749 2f3183ab11e78cd68633f82af0a0ec9b06919862
child 521751 6e4bbb9168097809542143faab0e357ebad42909
push id10867
push userdvarga@mozilla.com
push dateThu, 14 Mar 2019 15:20:45 +0000
treeherdermozilla-beta@abad13547875 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersannevk
bugs1085060
milestone67.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1085060 - update WPTs for XHR sends to also test with workers; r=annevk update WPTs for XHR sends to also test with workers Differential Revision: https://phabricator.services.mozilla.com/D23246
testing/web-platform/tests/xhr/send-data-arraybuffer.any.js
testing/web-platform/tests/xhr/send-data-arraybuffer.htm
testing/web-platform/tests/xhr/send-data-arraybufferview.any.js
testing/web-platform/tests/xhr/send-data-arraybufferview.htm
testing/web-platform/tests/xhr/send-data-es-object.any.js
testing/web-platform/tests/xhr/send-data-es-object.htm
testing/web-platform/tests/xhr/send-data-formdata.any.js
testing/web-platform/tests/xhr/send-data-formdata.htm
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/xhr/send-data-arraybuffer.any.js
@@ -0,0 +1,31 @@
+// META: title=XMLHttpRequest.send(arraybuffer)
+
+var test = async_test();
+test.step(function()
+{
+    var xhr = new XMLHttpRequest();
+    var buf = new ArrayBuffer(5);
+    var arr = new Uint8Array(buf);
+    arr[0] = 0x48;
+    arr[1] = 0x65;
+    arr[2] = 0x6c;
+    arr[3] = 0x6c;
+    arr[4] = 0x6f;
+
+    xhr.onreadystatechange = function()
+    {
+        if (xhr.readyState == 4)
+        {
+            test.step(function()
+            {
+                assert_equals(xhr.status, 200);
+                assert_equals(xhr.response, "Hello");
+
+                test.done();
+            });
+        }
+    };
+
+    xhr.open("POST", "./resources/content.py", true);
+    xhr.send(buf);
+});
deleted file mode 100644
--- a/testing/web-platform/tests/xhr/send-data-arraybuffer.htm
+++ /dev/null
@@ -1,48 +0,0 @@
-<!DOCTYPE html>
-<html>
-<head>
-    <link rel="help" href="https://xhr.spec.whatwg.org/#the-send()-method"  data-tested-assertations="following::ol[1]/li[4] following::ol[1]/li[4]/dl[1]/dd[1]"/>
-    <link rel="help" href="https://xhr.spec.whatwg.org/#the-status-attribute"  data-tested-assertations="following::ol[1]/li[3]"/>
-    <link rel="help" href="https://xhr.spec.whatwg.org/#the-response-attribute"  data-tested-assertations="following::ol[1]/li[3]"/>
-    <script src="/resources/testharness.js"></script>
-    <script src="/resources/testharnessreport.js"></script>
-    <title>XMLHttpRequest: The send() method: ArrayBuffer data</title>
-</head>
-
-<body>
-    <div id="log"></div>
-
-    <script type="text/javascript">
-        var test = async_test();
-
-        test.step(function()
-        {
-            var xhr = new XMLHttpRequest();
-            var buf = new ArrayBuffer(5);
-            var arr = new Uint8Array(buf);
-            arr[0] = 0x48;
-            arr[1] = 0x65;
-            arr[2] = 0x6c;
-            arr[3] = 0x6c;
-            arr[4] = 0x6f;
-
-            xhr.onreadystatechange = function()
-            {
-                if (xhr.readyState == 4)
-                {
-                    test.step(function()
-                    {
-                        assert_equals(xhr.status, 200);
-                        assert_equals(xhr.response, "Hello");
-
-                        test.done();
-                    });
-                }
-            };
-
-            xhr.open("POST", "./resources/content.py", true);
-            xhr.send(buf);
-        });
-    </script>
-</body>
-</html>
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/xhr/send-data-arraybufferview.any.js
@@ -0,0 +1,18 @@
+// META: title=XMLHttpRequest.send(arraybufferview)
+
+var test = async_test();
+test.step(function()
+{
+    var str = "Hello";
+    var bytes = str.split("").map(function(ch) { return ch.charCodeAt(0); });
+    var xhr = new XMLHttpRequest();
+    var arr = new Uint8Array(bytes);
+
+    xhr.onload = test.step_func_done(function() {
+        assert_equals(xhr.status, 200);
+        assert_equals(xhr.response, str);
+    });
+
+    xhr.open("POST", "./resources/content.py", true);
+    xhr.send(arr);
+});
deleted file mode 100644
--- a/testing/web-platform/tests/xhr/send-data-arraybufferview.htm
+++ /dev/null
@@ -1,36 +0,0 @@
-<!DOCTYPE html>
-<html>
-<head>
-    <link rel="help" href="https://xhr.spec.whatwg.org/#the-send()-method"  data-tested-assertations="following::ol[1]/li[4] following::ol[1]/li[4]/dl[1]/dd[1]"/>
-    <link rel="help" href="https://xhr.spec.whatwg.org/#the-status-attribute"  data-tested-assertations="following::ol[1]/li[3]"/>
-    <link rel="help" href="https://xhr.spec.whatwg.org/#the-response-attribute"  data-tested-assertations="following::ol[1]/li[3]"/>
-    <script src="/resources/testharness.js"></script>
-    <script src="/resources/testharnessreport.js"></script>
-    <title>XMLHttpRequest: The send() method: ArrayBufferView data</title>
-    <link rel="author" title="Ondrej Zara" href="mailto:ondrej.zara@gmail.com">
-</head>
-
-<body>
-    <div id="log"></div>
-
-    <script type="text/javascript">
-        var test = async_test();
-
-        test.step(function()
-        {
-            var str = "Hello";
-            var bytes = str.split("").map(function(ch) { return ch.charCodeAt(0); });
-            var xhr = new XMLHttpRequest();
-            var arr = new Uint8Array(bytes);
-
-            xhr.onload = test.step_func_done(function() {
-                assert_equals(xhr.status, 200);
-                assert_equals(xhr.response, str);
-            });
-
-            xhr.open("POST", "./resources/content.py", true);
-            xhr.send(arr);
-        });
-    </script>
-</body>
-</html>
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/xhr/send-data-es-object.any.js
@@ -0,0 +1,50 @@
+// META: title=XMLHttpRequest.send(ES object)
+
+function do_test(obj, expected, name) {
+  var test = async_test(name)
+  test.step(function() {
+    var client = new XMLHttpRequest()
+    client.onload = test.step_func(function () {
+      assert_equals(client.responseText, expected)
+      test.done()
+    });
+    client.open('POST', 'resources/content.py')
+    if (expected.exception) {
+      assert_throws(expected.exception, function(){client.send(obj)})
+      test.done()
+    } else {
+      client.send(obj)
+    }
+  });
+}
+
+do_test({}, '[object Object]', 'sending a plain empty object')
+do_test(Math, '[object Math]', 'sending the ES Math object')
+do_test(new XMLHttpRequest, '[object XMLHttpRequest]', 'sending a new XHR instance')
+do_test({toString:function(){}}, 'undefined', 'sending object that stringifies to undefined')
+do_test({toString:function(){return null}}, 'null', 'sending object that stringifies to null')
+var ancestor = {toString: function(){
+  var ar=[]
+  for (var prop in this) {
+    if (this.hasOwnProperty(prop)) {
+      ar.push(prop+'='+this[prop])
+    }
+  };
+  return ar.join('&')
+}};
+
+var myObj = Object.create(ancestor, {foo:{value:1, enumerable: true},  bar:{value:'foo', enumerable:true}})
+do_test(myObj, 'foo=1&bar=foo', 'object that stringifies to query string')
+
+var myFakeJSON = {a:'a', b:'b', toString:function(){ return JSON.stringify(this, function(key, val){ return key ==='toString'?undefined:val; }) }}
+do_test(myFakeJSON, '{"a":"a","b":"b"}', 'object that stringifies to JSON string')
+
+var myFakeDoc1 = {valueOf:function(){return document}}
+do_test(myFakeDoc1, '[object Object]', 'object whose valueOf() returns a document - ignore valueOf(), stringify')
+
+var myFakeDoc2 = {toString:function(){return document}}
+var expectedError = self.GLOBAL.isWorker() ? new ReferenceError() : new TypeError();
+do_test(myFakeDoc2, {exception:expectedError}, 'object whose toString() returns a document, expected to throw')
+
+var myThrower = {toString:function(){throw {name:'FooError', message:'bar'}}}
+do_test(myThrower, {exception:{name:'FooError'}}, 'object whose toString() throws, expected to throw')
deleted file mode 100644
--- a/testing/web-platform/tests/xhr/send-data-es-object.htm
+++ /dev/null
@@ -1,61 +0,0 @@
-<!doctype html>
-<meta charset=utf-8>
-<title>XMLHttpRequest: passing objects to send()</title>
-<script src="/resources/testharness.js"></script>
-<script src="/resources/testharnessreport.js"></script>
-<link rel="help" href="https://xhr.spec.whatwg.org/#the-send()-method" data-tested-assertations="following::ol/li[4]" />
-<link rel="help" href="https://heycam.github.io/webidl/#es-union" data-tested-assertations="following::ol/li[16]" />
-
-<div id="log"></div>
-
-<script>
-  function do_test(obj, expected, name) {
-    var test = async_test(name)
-    test.step(function() {
-      var client = new XMLHttpRequest()
-      client.onload = test.step_func(function () {
-        assert_equals(client.responseText, expected)
-        test.done()
-      });
-      client.open('POST', 'resources/content.py')
-      if (expected.exception) {
-        assert_throws(expected.exception, function(){client.send(obj)})
-        test.done()
-      } else {
-        client.send(obj)
-      }
-    });
-  }
-
-  do_test({}, '[object Object]', 'sending a plain empty object')
-  do_test(Math, '[object Math]', 'sending the ES Math object')
-  do_test(new XMLHttpRequest, '[object XMLHttpRequest]', 'sending a new XHR instance')
-  do_test({toString:function(){}}, 'undefined', 'sending object that stringifies to undefined')
-  do_test({toString:function(){return null}}, 'null', 'sending object that stringifies to null')
-  var ancestor = {toString: function(){
-    var ar=[]
-    for (var prop in this) {
-      if (this.hasOwnProperty(prop)) {
-        ar.push(prop+'='+this[prop])
-      }
-    };
-    return ar.join('&')
-  }};
-
-  var myObj = Object.create(ancestor, {foo:{value:1, enumerable: true},  bar:{value:'foo', enumerable:true}})
-  do_test(myObj, 'foo=1&bar=foo', 'object that stringifies to query string')
-
-  var myFakeJSON = {a:'a', b:'b', toString:function(){ return JSON.stringify(this, function(key, val){ return key ==='toString'?undefined:val; }) }}
-  do_test(myFakeJSON, '{"a":"a","b":"b"}', 'object that stringifies to JSON string')
-
-  var myFakeDoc1 = {valueOf:function(){return document}}
-  do_test(myFakeDoc1, '[object Object]', 'object whose valueOf() returns a document - ignore valueOf(), stringify')
-
-  var myFakeDoc2 = {toString:function(){return document}}
-  do_test(myFakeDoc2, {exception:new TypeError()}, 'object whose toString() returns a document, expected to throw')
-
-  var myThrower = {toString:function(){throw {name:'FooError', message:'bar'}}}
-  do_test(myThrower, {exception:{name:'FooError'}}, 'object whose toString() throws, expected to throw')
-
-
-</script>
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/xhr/send-data-formdata.any.js
@@ -0,0 +1,21 @@
+// META: title=XMLHttpRequest.send(formdata)
+
+var test = async_test();
+test.step(function()
+{
+    var xhr = new XMLHttpRequest();
+    var form = new FormData();
+    form.append("id", "0");
+    form.append("value", "zero");
+
+    xhr.onreadystatechange = test.step_func(() => {
+        if (xhr.readyState == 4) {
+            assert_equals(xhr.status, 200);
+            assert_equals(xhr.response, "id:0;value:zero;");
+            test.done();
+        }
+    });
+
+    xhr.open("POST", "./resources/form.py", true);
+    xhr.send(form);
+});
deleted file mode 100644
--- a/testing/web-platform/tests/xhr/send-data-formdata.htm
+++ /dev/null
@@ -1,38 +0,0 @@
-<!DOCTYPE html>
-<html>
-<head>
-    <link rel="help" href="https://xhr.spec.whatwg.org/#the-send()-method" data-tested-assertations="following::ol[1]/li[4] following::ol[1]/li[4]/dl[1]/dd[5]" />
-    <link rel="help" href="https://xhr.spec.whatwg.org/#interface-formdata" data-tested-assertations="following::*[contains(@id,'dom-formdata')]/following::ol[1]/li[1] following::*[contains(@id,'dom-formdata')]/following::ol[1]/li[3] following::*[contains(@id,'dom-formdata-append')]/following::ul[1]/li[1] following::*[contains(@id,'dom-formdata-append')]/following::ul[1]/li[2]" />
-    <link rel="help" href="https://xhr.spec.whatwg.org/#the-response-attribute"  data-tested-assertations="following::ol[1]/li[3]"/>
-    <script src="/resources/testharness.js"></script>
-    <script src="/resources/testharnessreport.js"></script>
-    <title>XMLHttpRequest: The send() method: FormData data</title>
-</head>
-
-<body>
-    <div id="log"></div>
-
-    <script type="text/javascript">
-        var test = async_test();
-
-        test.step(function()
-        {
-            var xhr = new XMLHttpRequest();
-            var form = new FormData();
-            form.append("id", "0");
-            form.append("value", "zero");
-
-            xhr.onreadystatechange = test.step_func(() => {
-                if (xhr.readyState == 4) {
-                    assert_equals(xhr.status, 200);
-                    assert_equals(xhr.response, "id:0;value:zero;");
-                    test.done();
-                }
-            });
-
-            xhr.open("POST", "./resources/form.py", true);
-            xhr.send(form);
-        });
-    </script>
-</body>
-</html>