-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
LibWeb/FileAPI: Implement aborting a FileReader read
This fixes a timeout for the included WPT test.
- Loading branch information
1 parent
b1ef9e5
commit fbb9b28
Showing
5 changed files
with
153 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
...b/Text/expected/wpt-import/FileAPI/reading-data-section/FileReader-multiple-reads.any.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
Harness status: OK | ||
|
||
Found 6 tests | ||
|
||
6 Pass | ||
Pass test FileReader InvalidStateError exception for readAsText | ||
Pass test FileReader InvalidStateError exception for readAsDataURL | ||
Pass test FileReader InvalidStateError exception for readAsArrayBuffer | ||
Pass test FileReader InvalidStateError exception in onloadstart event for readAsArrayBuffer | ||
Pass test FileReader no InvalidStateError exception in loadend event handler for readAsArrayBuffer | ||
Pass test abort and restart in onloadstart event for readAsText |
15 changes: 15 additions & 0 deletions
15
...Web/Text/input/wpt-import/FileAPI/reading-data-section/FileReader-multiple-reads.any.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<!doctype html> | ||
<meta charset=utf-8> | ||
<title>FileReader: starting new reads while one is in progress</title> | ||
<script> | ||
self.GLOBAL = { | ||
isWindow: function() { return true; }, | ||
isWorker: function() { return false; }, | ||
isShadowRealm: function() { return false; }, | ||
}; | ||
</script> | ||
<script src="../../resources/testharness.js"></script> | ||
<script src="../../resources/testharnessreport.js"></script> | ||
|
||
<div id=log></div> | ||
<script src="../../FileAPI/reading-data-section/FileReader-multiple-reads.any.js"></script> |
81 changes: 81 additions & 0 deletions
81
...ibWeb/Text/input/wpt-import/FileAPI/reading-data-section/FileReader-multiple-reads.any.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
// META: title=FileReader: starting new reads while one is in progress | ||
|
||
test(function() { | ||
var blob_1 = new Blob(['TEST000000001']) | ||
var blob_2 = new Blob(['TEST000000002']) | ||
var reader = new FileReader(); | ||
reader.readAsText(blob_1) | ||
assert_equals(reader.readyState, FileReader.LOADING, "readyState Must be LOADING") | ||
assert_throws_dom("InvalidStateError", function () { | ||
reader.readAsText(blob_2) | ||
}) | ||
}, 'test FileReader InvalidStateError exception for readAsText'); | ||
|
||
test(function() { | ||
var blob_1 = new Blob(['TEST000000001']) | ||
var blob_2 = new Blob(['TEST000000002']) | ||
var reader = new FileReader(); | ||
reader.readAsDataURL(blob_1) | ||
assert_equals(reader.readyState, FileReader.LOADING, "readyState Must be LOADING") | ||
assert_throws_dom("InvalidStateError", function () { | ||
reader.readAsDataURL(blob_2) | ||
}) | ||
}, 'test FileReader InvalidStateError exception for readAsDataURL'); | ||
|
||
test(function() { | ||
var blob_1 = new Blob(['TEST000000001']) | ||
var blob_2 = new Blob(['TEST000000002']) | ||
var reader = new FileReader(); | ||
reader.readAsArrayBuffer(blob_1) | ||
assert_equals(reader.readyState, FileReader.LOADING, "readyState Must be LOADING") | ||
assert_throws_dom("InvalidStateError", function () { | ||
reader.readAsArrayBuffer(blob_2) | ||
}) | ||
}, 'test FileReader InvalidStateError exception for readAsArrayBuffer'); | ||
|
||
async_test(function() { | ||
var blob_1 = new Blob(['TEST000000001']) | ||
var blob_2 = new Blob(['TEST000000002']) | ||
var reader = new FileReader(); | ||
var triggered = false; | ||
reader.onloadstart = this.step_func_done(function() { | ||
assert_false(triggered, "Only one loadstart event should be dispatched"); | ||
triggered = true; | ||
assert_equals(reader.readyState, FileReader.LOADING, | ||
"readyState must be LOADING") | ||
assert_throws_dom("InvalidStateError", function () { | ||
reader.readAsArrayBuffer(blob_2) | ||
}) | ||
}); | ||
reader.readAsArrayBuffer(blob_1) | ||
assert_equals(reader.readyState, FileReader.LOADING, "readyState Must be LOADING") | ||
}, 'test FileReader InvalidStateError exception in onloadstart event for readAsArrayBuffer'); | ||
|
||
async_test(function() { | ||
var blob_1 = new Blob(['TEST000000001']) | ||
var blob_2 = new Blob(['TEST000000002']) | ||
var reader = new FileReader(); | ||
reader.onloadend = this.step_func_done(function() { | ||
assert_equals(reader.readyState, FileReader.DONE, | ||
"readyState must be DONE") | ||
reader.readAsArrayBuffer(blob_2) | ||
assert_equals(reader.readyState, FileReader.LOADING, "readyState Must be LOADING") | ||
}); | ||
reader.readAsArrayBuffer(blob_1) | ||
assert_equals(reader.readyState, FileReader.LOADING, "readyState Must be LOADING") | ||
}, 'test FileReader no InvalidStateError exception in loadend event handler for readAsArrayBuffer'); | ||
|
||
async_test(function() { | ||
var blob_1 = new Blob([new Uint8Array(0x414141)]); | ||
var blob_2 = new Blob(['TEST000000002']); | ||
var reader = new FileReader(); | ||
reader.onloadstart = this.step_func(function() { | ||
reader.abort(); | ||
reader.onloadstart = null; | ||
reader.onloadend = this.step_func_done(function() { | ||
assert_equals('TEST000000002', reader.result); | ||
}); | ||
reader.readAsText(blob_2); | ||
}); | ||
reader.readAsText(blob_1); | ||
}, 'test abort and restart in onloadstart event for readAsText'); |