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

Unified Diff: LayoutTests/fast/files/file-constructor.html

Issue 74213009: File constructor understands lastModified. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Reduce sketchiness of comparison against Date.now() in test. 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/file-constructor.html
diff --git a/LayoutTests/fast/files/file-constructor.html b/LayoutTests/fast/files/file-constructor.html
index f615864f75e496d559deab8828f0874b669cf0b7..a62aa503e163c4cf5982e87d1a92ef072e4d4e53 100644
--- a/LayoutTests/fast/files/file-constructor.html
+++ b/LayoutTests/fast/files/file-constructor.html
@@ -69,6 +69,9 @@ shouldThrow("new File([], 'world.html', {endings:'illegalValue'})", "'TypeError:
shouldThrow("new File([], 'world.html', {endings:throwingObj})", "'Error'");
shouldThrow("new File([], 'world.html', {type:throwingObj})", "'Error'");
shouldThrow("new File([], 'world.html', {type:'hello\u00EE'})", "'SyntaxError: Failed to construct \\'File\\': The \"type\" property must consist of ASCII characters.'");
+shouldThrow("new File([], 'world.html', {lastModifiedDate: 'not a date'})", "'TypeError: Failed to construct \\'File\\': The \"lastModifiedDate\" property must be a Date instance.'");
+shouldThrow("new File([], 'world.html', {lastModifiedDate: null})", "'TypeError: Failed to construct \\'File\\': The \"lastModifiedDate\" property must be a Date instance.'");
+shouldThrow("new File([], 'world.html', {lastModifiedDate: Date.now()})", "'TypeError: Failed to construct \\'File\\': The \"lastModifiedDate\" property must be a Date instance.'");
// Test various non-object literals being used as property bags.
shouldThrow("(new File([], 'world.html', null)) instanceof window.File", "'TypeError: Failed to construct \\'File\\': The 3rd argument is not of type Object.'");
@@ -87,6 +90,27 @@ shouldBe("(new File([], 'world.html', {type:'text/html'})).type", "'text/html'")
shouldBe("(new File([], 'world.html', {type:'text/html'})).size", "0");
shouldBe("(new File([], 'world.html', {type:'text/plain;charset=UTF-8'})).type", "'text/plain;charset=utf-8'");
+// Test that the lastModificationDate is correctly added to the File.
+var aDate = new Date(441532800000);
+shouldBeTrue("(new File([], 'world.html', {lastModifiedDate: aDate})).lastModifiedDate instanceof Date");
+shouldBe("(new File([], 'world.html', {lastModifiedDate: aDate})).lastModifiedDate.valueOf()", "aDate.valueOf()");
+shouldBeTrue("(new File([], 'world.html', {lastModifiedDate: new Date(NaN)})).lastModifiedDate instanceof Date");
+shouldBeNaN("(new File([], 'world.html', {lastModifiedDate: new Date(NaN)})).lastModifiedDate.valueOf()");
+// Unless specified, lastModifiedDate should default to now.
+shouldBeTrue("(new File([], 'world.html')).lastModifiedDate instanceof Date");
+while (true) {
+ var startTime = Date.now();
+ var fileTime = (new File([], 'world.html')).lastModifiedDate.valueOf();
+ var endTime = Date.now();
+
+ if (startTime > endTime)
+ continue; // Time went backwards. (DST)
kinuko 2013/11/18 13:27:09 Ah oh. Right time could go backwards... maybe we c
pwnall-personal 2013/11/18 13:47:34 I just started doing that, then realized that skip
kinuko 2013/11/18 13:57:58 I see, sounds good, could we then remove this DST
pwnall-personal 2013/11/18 14:04:55 Done. Good point, thank you!
+
+ shouldBeTrue("startTime <= fileTime");
+ shouldBeTrue("fileTime <= endTime");
+ break;
+}
+
// Test the number of expected arguments in the File constructor.
shouldBe("window.File.length", "2");
« no previous file with comments | « LayoutTests/fast/files/blob-constructor-expected.txt ('k') | LayoutTests/fast/files/file-constructor-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698