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

Side by Side Diff: chrome/test/data/chrome_endure/webpagereplay/wpr_deterministic.js

Issue 10803002: Run Chrome Endure tests with network simulation via Web Page Replay. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address Nirnimesh, Dennis, Steve's comments Created 8 years, 4 months 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 /* Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 * Use of this source code is governed by a BSD-style license that can be
3 * found in the LICENSE file.
4 *
5 * The scripts in this file will be injected to the http responses when
6 * simulating network via Web Page Replay for Chrome Endure tests.
7 *
8 * If you need to modify this scripts, make sure that you use the same version
9 * of this scripts in both record and replay mode.
10 *
11 * TODO(fdeng):
12 * This file is adapted from deterministic.js in Web Page Replay project.
13 * http://code.google.com/p/web-page-replay/source/browse/trunk/deterministic.js
14 * The value of time_seed is modified to a date far in the future.
15 * This is a workaround for Endure tests for Google apps like Gmail.
16 * The side effect of a future date is unknown and needs future investigation.
17 * A better way to go is to revise the time_seed to
18 * current time each time we record and use the revised scripts for replay.
19 * This can be achieved by modifying Web Page Replay to automatically
20 * revise and save scripts in the archive in record mode and read it
21 * from the archive in replay mode.
22 */
23 (function () {
24 var orig_date = Date;
25 var random_count = 0;
26 var date_count = 0;
27 var random_seed = 0.462;
28 var time_seed = 3204251968254; // Changed from default value 1204251968254
29 var random_count_threshold = 25;
30 var date_count_threshold = 25;
31 Math.random = function() {
32 random_count++;
33 if (random_count > random_count_threshold) {
34 random_seed += 0.1;
35 random_count = 1;
36 }
37 return (random_seed % 1);
38 };
39 Date = function() {
40 if (this instanceof Date) {
41 date_count++;
42 if (date_count > date_count_threshold) {
43 time_seed += 50;
44 date_count = 1;
45 }
46 switch (arguments.length) {
47 case 0: return new orig_date(time_seed);
48 case 1: return new orig_date(arguments[0]);
49 default: return new orig_date(arguments[0], arguments[1],
50 arguments.length >= 3 ? arguments[2] : 1,
51 arguments.length >= 4 ? arguments[3] : 0,
52 arguments.length >= 5 ? arguments[4] : 0,
53 arguments.length >= 6 ? arguments[5] : 0,
54 arguments.length >= 7 ? arguments[6] : 0);
55 }
56 }
57 return new Date().toString();
58 };
59 Date.__proto__ = orig_date;
60 Date.prototype.constructor = Date;
61 orig_date.now = function() {
62 return new Date().getTime();
63 };
64 })();
OLDNEW
« no previous file with comments | « no previous file | chrome/test/functional/perf_endure.py » ('j') | chrome/test/functional/perf_endure.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698