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

Unified Diff: LayoutTests/fast/files/resources/blob-slice-common.js

Issue 57483002: Implement File constructor. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Answered feedback, part 2. Created 7 years, 1 month 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: LayoutTests/fast/files/resources/blob-slice-common.js
diff --git a/LayoutTests/fast/files/resources/blob-slice-common.js b/LayoutTests/fast/files/resources/blob-slice-common.js
new file mode 100644
index 0000000000000000000000000000000000000000..ff3d7e7b6028656b54e1316495af2c3a2e3ca65a
--- /dev/null
+++ b/LayoutTests/fast/files/resources/blob-slice-common.js
@@ -0,0 +1,68 @@
+var blob, file; // Populated by runTests() in individual tests.
+var sliceParams = []; // Populated by individual tests.
+var testIndex = 0;
+
+function log(message)
+{
+ document.getElementById('console').appendChild(document.createTextNode(message + "\n"));
+}
+
+function testSlicing(start, end)
+{
+ var subBlob, subFile;
+ var blobReader = new FileReader();
+ var fileReader = new FileReader();
+ var message = "sliced ";
+ if (start == undefined && end == undefined) {
+ message += "without parameters";
+ subBlob = blob.slice();
+ subFile = file.slice();
+ } else if (end == undefined) {
+ message += "from " + start;
+ subBlob = blob.slice(start);
+ subFile = file.slice(start);
+ } else {
+ message += "from " + start + " to " + end;
+ subBlob = blob.slice(start, end);
+ subFile = file.slice(start, end);
+ }
+ message += ": ";
+ blobReader.onload = function(event) {
+ log("Blob " + message + event.target.result + ".");
+ fileReader.readAsText(subFile);
+ };
+ blobReader.onerror = function(event) {
+ log("Blob " + message + "error " + event.target.error.message);
+ fileReader.readAsText(subFile);
+ };
+ fileReader.onload = function(event) {
+ log("File " + message + event.target.result + ".");
+ runNextTest();
+ };
+ fileReader.onerror = function(event) {
+ log("File " + message + "error " + event.target.error.message);
+ runNextTest();
+ }
+ blobReader.readAsText(subBlob);
+}
+
+function runNextTest()
+{
+ if (testIndex >= sliceParams.length) {
+ if (window.testRunner)
+ testRunner.notifyDone();
+ return;
+ }
+
+ var start = sliceParams[testIndex][0];
+ var end = sliceParams[testIndex][1];
+ testIndex++;
+ testSlicing(start, end);
+}
+
+window.onerror = function(message)
+{
+ log("ERROR: " + message);
+ if (window.testRunner)
+ testRunner(notifyDone());
esprehn 2013/11/04 19:28:08 You don't need this, js-test-pre should do it for
pwnall-personal 2013/11/04 23:01:21 These tests weren't using js-test-pre. I reworked
+}

Powered by Google App Engine
This is Rietveld 408576698