Commit a022a1a9 authored by Michael Achenbach's avatar Michael Achenbach Committed by Commit Bot

[foozzie] More robust Date mock

Later manipulation of Array.prototype.concat could lead to calling the Date constructor with empty arguments list. This let a non-mocked date slip in.

BUG=chromium:698097
NOTRY=true
TBR=yangguo@chromium.org,mstarzinger@chromium.org

Change-Id: Ib4bd97e06ea7be8c32d0057d42943f9f82ea6b5f
Reviewed-on: https://chromium-review.googlesource.com/449732Reviewed-by: 's avatarMichael Achenbach <machenbach@chromium.org>
Commit-Queue: Michael Achenbach <machenbach@chromium.org>
Cr-Commit-Position: refs/heads/master@{#43570}
parent bf84d924
......@@ -31,11 +31,13 @@ var __PrettyPrint = function __PrettyPrint(msg) { print(msg); };
return mockDate
}
var origConcat = Array.prototype.concat
var origDate = Date;
var constructDate = function(args) {
if (args.length > 0) {
var result = new (
Function.prototype.bind.apply(origDate, [null].concat(args)));
Function.prototype.bind.apply(
origDate, origConcat.apply([null], args)));
} else {
var result = new origDate(mockDateNow());
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment