Only grant permissions to new extensions from sync if they have the expected version
[chromium-blink-merge.git] / tools / telemetry / third_party / webpagereplay / deterministic.js
bloba8e0ce91702ed53efa38e54a4a7d739b1b8a2ef8
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;
11 return (random_seed % 1);
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);
20 return arr;
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;
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);
47 return new Date().toString();
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();
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;
62 })();