| Index: third_party/WebKit/LayoutTests/http/tests/xmlhttprequest/upload-progress-events-handlers-must-be-set-before-send.html
|
| diff --git a/third_party/WebKit/LayoutTests/http/tests/xmlhttprequest/upload-progress-events-handlers-must-be-set-before-send.html b/third_party/WebKit/LayoutTests/http/tests/xmlhttprequest/upload-progress-events-handlers-must-be-set-before-send.html
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..8db8fcaaf73a72d392a6e2688974837a54f57d13
|
| --- /dev/null
|
| +++ b/third_party/WebKit/LayoutTests/http/tests/xmlhttprequest/upload-progress-events-handlers-must-be-set-before-send.html
|
| @@ -0,0 +1,89 @@
|
| +<!doctype html>
|
| +<script src="/resources/testharness.js"></script>
|
| +<script src="/resources/testharnessreport.js"></script>
|
| +<script type="text/javascript">
|
| +async_test(test => {
|
| + const xhr = new XMLHttpRequest();
|
| + xhr.open("POST", "resources/post-echo.php", true);
|
| + xhr.send('hello');
|
| +
|
| + const upload = xhr.upload;
|
| + upload.onloadstart = test.step_func(() => {
|
| + assert_unreached('Unexpected upload.onloadstart call');
|
| + });
|
| + upload.onprogress = test.step_func(() => {
|
| + assert_unreached('Unexpected upload.onprogress call');
|
| + });
|
| + upload.onload = test.step_func(() => {
|
| + assert_unreached('Unexpected upload.onload call');
|
| + });
|
| + upload.onloadend = test.step_func(() => {
|
| + assert_unreached('Unexpected upload.onloadend call');
|
| + });
|
| +
|
| + xhr.onload = test.step_func(() => {
|
| + test.done();
|
| + });
|
| +}, 'Upload progress events should not be dispatched if the handlers are set after send().');
|
| +
|
| +async_test(test => {
|
| + const xhr = new XMLHttpRequest();
|
| + xhr.open("POST", "resources/post-echo.php", true);
|
| +
|
| + const upload = xhr.upload;
|
| +
|
| + xhr.send('hello');
|
| +
|
| + upload.onloadstart = test.step_func(() => {
|
| + assert_unreached('Unexpected upload.onloadstart call');
|
| + });
|
| + upload.onprogress = test.step_func(() => {
|
| + assert_unreached('Unexpected upload.onprogress call');
|
| + });
|
| + upload.onload = test.step_func(() => {
|
| + assert_unreached('Unexpected upload.onload call');
|
| + });
|
| + upload.onloadend = test.step_func(() => {
|
| + assert_unreached('Unexpected upload.onloadend call');
|
| + });
|
| +
|
| + xhr.onload = test.step_func(() => {
|
| + test.done();
|
| + });
|
| +}, 'Upload progress events should not be dispatched even if the upload atrribute is touched before send().');
|
| +
|
| +async_test(test => {
|
| + const xhr = new XMLHttpRequest();
|
| + xhr.open("POST", "resources/post-echo.php", true);
|
| +
|
| + const upload = xhr.upload;
|
| + let onloadstartCalled;
|
| + upload.onloadstart = test.step_func(() => {
|
| + onloadstartCalled = true;
|
| + });
|
| +
|
| + xhr.send('hello');
|
| +
|
| + let onprogressCalled;
|
| + upload.onprogress = test.step_func(() => {
|
| + onprogressCalled = true;
|
| + });
|
| + let onloadCalled;
|
| + upload.onload = test.step_func(() => {
|
| + onloadCalled = true;
|
| + });
|
| + let onloadendCalled;
|
| + upload.onloadend = test.step_func(() => {
|
| + onloadendCalled = true;
|
| + });
|
| +
|
| + xhr.onload = test.step_func(() => {
|
| + assert_true(onloadstartCalled, 'upload.onloadstart is called');
|
| + assert_true(onprogressCalled, 'upload.onprogress is called');
|
| + assert_true(onloadCalled, 'upload.onload is called');
|
| + assert_true(onloadendCalled, 'upload.onloadend is called');
|
| +
|
| + test.done();
|
| + });
|
| +}, 'All upload progress events should be dispatched if at least one handler is set to the upload atrribute before send().');
|
| +</script>
|
|
|