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

Side by Side Diff: chrome/test/data/chrome_endure/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: Env var to control usage of WPR Created 8 years, 5 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
« no previous file with comments | « no previous file | chrome/test/functional/perf.py » ('j') | chrome/test/functional/perf.py » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
dennis_jeffrey 2012/07/24 00:39:35 could we give this file a new name? Something to
fdeng1 2012/07/24 04:30:05 Done.
2 * Copyright 2012, Google Inc.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met:
8 *
9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * * Redistributions in binary form must reproduce the above
12 * copyright notice, this list of conditions and the following disclaimer
13 * in the documentation and/or other materials provided with the
14 * distribution.
15 * * Neither the name of Google Inc. nor the names of its
16 * contributors may be used to endorse or promote products derived from
17 * this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
dennis_jeffrey 2012/07/24 00:39:35 We should probably use the regular 3-line chromium
fdeng1 2012/07/24 04:30:05 Done.
31
32 /*
33 * The scripts in this file will be injected to the http responses when
34 * simulating network via Web Page Replay for Chrome Endure tests.
35 *
36 * If you need to modify this scripts, make sure that you use the same version
37 * of this scripts in both record and replay mode.
dennis_jeffrey 2012/07/24 00:39:35 you might want to mention that this script is adap
fdeng1 2012/07/24 04:30:05 Done.
38 *
39 * TODO(fdeng): Currently the time_seed is set to a date far in the future.
40 * This might cause problems but it is the workaround for Endure tests for
41 * Google apps like Gmail. A better way to go is to revise the time_seed to
42 * current time each time we record and use the revised scripts for replay.
43 * This can be achieved by modifying Web Page Replay to automaticly
dennis_jeffrey 2012/07/24 00:39:35 automaticly --> automatically
fdeng1 2012/07/24 04:30:05 Done.
44 * revise and save scripts in the archive in record mode and read it
45 * from the archive in replay mode.
46 */
47 (function () {
48 var orig_date = Date;
49 var random_count = 0;
50 var date_count = 0;
51 var random_seed = 0.462;
52 var time_seed = 3204251968254;
dennis_jeffrey 2012/07/24 00:39:35 var time_seed = 3204251968254; # Changed from def
fdeng1 2012/07/24 04:30:05 Done.
53 var random_count_threshold = 25;
54 var date_count_threshold = 25;
55 Math.random = function() {
56 random_count++;
57 if (random_count > random_count_threshold){
dennis_jeffrey 2012/07/24 00:39:35 add a space right before {
fdeng1 2012/07/24 04:30:05 Done.
58 random_seed += 0.1;
59 random_count = 1;
60 }
61 return (random_seed % 1);
62 };
63 Date = function() {
64 if (this instanceof Date) {
65 date_count++;
66 if (date_count > date_count_threshold){
dennis_jeffrey 2012/07/24 00:39:35 add a space right before {
fdeng1 2012/07/24 04:30:05 Done.
67 time_seed += 50;
68 date_count = 1;
69 }
70 switch (arguments.length) {
71 case 0: return new orig_date(time_seed);
72 case 1: return new orig_date(arguments[0]);
73 default: return new orig_date(arguments[0], arguments[1],
74 arguments.length >= 3 ? arguments[2] : 1,
75 arguments.length >= 4 ? arguments[3] : 0,
76 arguments.length >= 5 ? arguments[4] : 0,
77 arguments.length >= 6 ? arguments[5] : 0,
78 arguments.length >= 7 ? arguments[6] : 0);
79 }
80 }
81 return new Date().toString();
82 };
83 Date.__proto__ = orig_date;
84 Date.prototype.constructor = Date;
85 orig_date.now = function() {
86 return new Date().getTime();
87 };
88 })();
OLDNEW
« no previous file with comments | « no previous file | chrome/test/functional/perf.py » ('j') | chrome/test/functional/perf.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698