Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(37)

Unified Diff: third_party/WebKit/LayoutTests/http/tests/xmlhttprequest/non-simple-cross-origin-progress-events.html

Issue 2427553002: Fix XHR's logic to determine whether or not to dispatch upload progress events
Patch Set: a Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/http/tests/xmlhttprequest/non-simple-cross-origin-progress-events.html
diff --git a/third_party/WebKit/LayoutTests/http/tests/xmlhttprequest/non-simple-cross-origin-progress-events.html b/third_party/WebKit/LayoutTests/http/tests/xmlhttprequest/non-simple-cross-origin-progress-events.html
new file mode 100644
index 0000000000000000000000000000000000000000..b1259d98e4d6410ea8c5d04f6dea31a410e8315c
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/http/tests/xmlhttprequest/non-simple-cross-origin-progress-events.html
@@ -0,0 +1,42 @@
+<!doctype html>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script>
+// A simple cross-origin request means a cross-origin request with only
+// CORS-safelisted method and request-headers.
+
+async_test(test => {
+ const xhr = new XMLHttpRequest();
+ let onprogressCalled;
+ xhr.onprogress = test.step_func(() => {
+ onprogressCalled = true;
+ });
+ xhr.onload = test.step_func(() => {
+ assert_true(onprogressCalled, 'onprogress is called');
+
+ assert_true(uploadOnprogressCalled, 'upload.onprogress is called');
+ assert_true(uploadOnloadCalled, 'upload.onload is called');
+
+ test.done();
+ });
+
+ // Set handlers after send()
+ const upload = xhr.upload;
+ let uploadOnprogressCalled;
+ upload.onprogress = test.step_func(() => {
+ uploadOnprogressCalled = true;
+ });
+ let onloadCalled;
+ upload.onload = test.step_func(() => {
+ uploadOnloadCalled = true;
+ });
+
+ // Use the script which responds to OPTIONS requests.
+ const params = new URLSearchParams();
+ params.append('origin', 'http://127.0.0.1:8000');
+ params.append('headers', 'test');
+ xhr.open('POST', 'http://localhost:8000/xmlhttprequest/resources/access-control-allow-lists.php?' + params.toString(), true);
+ xhr.setRequestHeader("test", "test");
+ xhr.send('hello');
+}, 'Upload progress events should be dispatched for a non-simple cross-origin request');
+</script>

Powered by Google App Engine
This is Rietveld 408576698