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

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: Addressed most feedback. 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..ba7a2517f6a8631c09af751c505eb155aeb7bf37
--- /dev/null
+++ b/LayoutTests/fast/files/resources/blob-slice-common.js
@@ -0,0 +1,49 @@
+var blob, file; // Populated by runTests() in individual tests.
+var sliceParams = []; // Populated by individual tests.
+var testIndex = 0;
+
+function testSlicing(start, end, expectedResult, blob, doneCallback)
+{
+ var blobClass = blob.constructor.name;
+ var sliced;
+ var reader = new FileReader();
+ var message = ".slice";
+ if (start === null && end === null) {
+ message += "()";
+ sliced = blob.slice();
+ } else if (end == undefined) {
+ message += "(" + start + ")";
+ sliced = blob.slice(start);
+ } else {
+ message += "(" + start + ", " + end + ")";
+ sliced = blob.slice(start, end);
+ }
+ reader.onloadend = function(event) {
+ var error = event.target.error;
+ if (error) {
+ testFailed("File read error " + message + error);
+ doneCallback();
+ return;
+ }
+ var blobContentsVar = blobClass.toLowerCase() + "Contents";
+ window[blobContentsVar] = event.target.result;
+ shouldBeEqualToString(blobContentsVar, expectedResult);
+ doneCallback();
+ };
+ debug(blobClass + " " + message);
+ reader.readAsText(sliced);
+}
+
+function runNextTest()
+{
+ if (testIndex >= sliceTestCases.length) {
+ finishJSTest();
+ return;
+ }
+
+ var testCase = sliceTestCases[testIndex];
+ testIndex++;
+ testSlicing(testCase[0], testCase[1], testCase[2], blob, function() {
+ testSlicing(testCase[0], testCase[1], testCase[2], file, runNextTest);
+ });
+}
« no previous file with comments | « LayoutTests/fast/files/file-constructor-expected.txt ('k') | LayoutTests/fast/files/script-tests/blob-constructor.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698