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

Side by Side Diff: telemetry/third_party/webpagereplay/deterministic.js

Issue 2210063003: Rename third_party/webpagereplay to third_party/web-page-replay (Closed) Base URL: https://github.com/catapult-project/catapult@master
Patch Set: Created 4 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
OLDNEW
(Empty)
1 (function () {
2 var random_count = 0;
3 var random_count_threshold = 25;
4 var random_seed = 0.462;
5 Math.random = function() {
6 random_count++;
7 if (random_count > random_count_threshold){
8 random_seed += 0.1;
9 random_count = 1;
10 }
11 return (random_seed % 1);
12 };
13 if (typeof(crypto) == 'object' &&
14 typeof(crypto.getRandomValues) == 'function') {
15 crypto.getRandomValues = function(arr) {
16 var scale = Math.pow(256, arr.BYTES_PER_ELEMENT);
17 for (var i = 0; i < arr.length; i++) {
18 arr[i] = Math.floor(Math.random() * scale);
19 }
20 return arr;
21 };
22 }
23 })();
24 (function () {
25 var date_count = 0;
26 var date_count_threshold = 25;
27 var orig_date = Date;
28 var time_seed = 1204251968254;
29 Date = function() {
30 if (this instanceof Date) {
31 date_count++;
32 if (date_count > date_count_threshold){
33 time_seed += 50;
34 date_count = 1;
35 }
36 switch (arguments.length) {
37 case 0: return new orig_date(time_seed);
38 case 1: return new orig_date(arguments[0]);
39 default: return new orig_date(arguments[0], arguments[1],
40 arguments.length >= 3 ? arguments[2] : 1,
41 arguments.length >= 4 ? arguments[3] : 0,
42 arguments.length >= 5 ? arguments[4] : 0,
43 arguments.length >= 6 ? arguments[5] : 0,
44 arguments.length >= 7 ? arguments[6] : 0);
45 }
46 }
47 return new Date().toString();
48 };
49 Date.__proto__ = orig_date;
50 Date.prototype = orig_date.prototype;
51 Date.prototype.constructor = Date;
52 orig_date.now = function() {
53 return new Date().getTime();
54 };
55 orig_date.prototype.getTimezoneOffset = function() {
56 var dst2010Start = 1268560800000;
57 var dst2010End = 1289120400000;
58 if (this.getTime() >= dst2010Start && this.getTime() < dst2010End)
59 return 420;
60 return 480;
61 };
62 })();
OLDNEW
« no previous file with comments | « telemetry/third_party/webpagereplay/daemonserver.py ('k') | telemetry/third_party/webpagereplay/dnsproxy.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698