Bug 1346767 - Part 2: Make sure xhr.upload event listeners will be ignored if listeners are registered after send(), r=baku
authorShawn Huang <shuang@mozilla.com>
Mon, 24 Jul 2017 19:52:22 +0800
changeset 419291 4377bafde262dfe03a76c94d365df0cf535f45fc
parent 419290 f0817bf2f80b3f4cf8ea2d4f98904c23bce9b9b3
child 419292 7c3361a87e461937246b93743a87e1869bf080af
push id7566
push usermtabara@mozilla.com
push dateWed, 02 Aug 2017 08:25:16 +0000
treeherdermozilla-beta@86913f512c3c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbaku
bugs1346767
milestone56.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 1346767 - Part 2: Make sure xhr.upload event listeners will be ignored if listeners are registered after send(), r=baku
testing/web-platform/tests/XMLHttpRequest/event-upload-progress-crossorigin.htm
--- a/testing/web-platform/tests/XMLHttpRequest/event-upload-progress-crossorigin.htm
+++ b/testing/web-platform/tests/XMLHttpRequest/event-upload-progress-crossorigin.htm
@@ -1,26 +1,33 @@
 <!doctype html>
 <html lang=en>
 <meta charset=utf-8>
 <title>XMLHttpRequest: upload progress event for cross-origin requests</title>
 <script src="/resources/testharness.js"></script>
 <script src="/resources/testharnessreport.js"></script>
-    <link rel="help" href="https://xhr.spec.whatwg.org/#handler-xhr-onprogress" data-tested-assertations="../.." />
-    <link rel="help" href="https://xhr.spec.whatwg.org/#the-send()-method" data-tested-assertations="following::*//a[contains(@href,'#make-upload-progress-notifications')] following::ol[1]/li[8]" />
-    <link rel="help" href="https://xhr.spec.whatwg.org/#dom-xmlhttprequest-upload" data-tested-assertations=".." />
-
+<script src="/common/get-host-info.sub.js"></script>
 <div id="log"></div>
-<script src="/common/get-host-info.sub.js"></script>
 <script>
-  var test = async_test();
-  test.step(function() {
-    var client = new XMLHttpRequest();
-    client.upload.onprogress = test.step_func(function() {
-      test.done();
-    });
-    client.onload = test.step_func(function() {
-      assert_unreached("onprogress not called.");
-    });
-    client.open("POST", get_host_info().HTTP_REMOTE_ORIGIN + "/XMLHttpRequest/resources/corsenabled.py");
-    client.send("This is a test string.");
-  });
+const remote = get_host_info().HTTP_REMOTE_ORIGIN + "/XMLHttpRequest/resources/corsenabled.py",
+      redirect = "resources/redirect.py?code=307&location=" + remote;
+
+[remote, redirect].forEach(url => {
+  async_test(test => {
+    const client = new XMLHttpRequest();
+    client.upload.onprogress = test.step_func_done()
+    client.onload = test.unreached_func()
+    client.open("POST", url)
+    client.send("On time: " + url)
+  }, "Upload events registered on time (" + url + ")");
+});
+
+[remote, redirect].forEach(url => {
+  async_test(test => {
+    const client = new XMLHttpRequest();
+    client.onload = test.step_func_done();
+    client.open("POST", url);
+    client.send("Too late: " + url);
+    client.upload.onloadstart = test.unreached_func(); // registered too late
+    client.upload.onprogress = test.unreached_func(); // registered too late
+  }, "Upload events registered too late (" + url + ")");
+});
 </script>