mirror of
https://github.com/webrecorder/pywb.git
synced 2025-03-24 06:59:52 +01:00
wombat: ensure Math.random() overrides use the current window
This commit is contained in:
parent
1e7d4d27e3
commit
e5e7c5a7df
@ -667,15 +667,15 @@ var wombat_internal = function($wbwindow) {
|
|||||||
// Adapted from:
|
// Adapted from:
|
||||||
// http://indiegamr.com/generate-repeatable-random-numbers-in-js/
|
// http://indiegamr.com/generate-repeatable-random-numbers-in-js/
|
||||||
|
|
||||||
Math.seed = parseInt(seed);
|
$wbwindow.Math.seed = parseInt(seed);
|
||||||
function seeded_random() {
|
function seeded_random() {
|
||||||
Math.seed = (Math.seed * 9301 + 49297) % 233280;
|
$wbwindow.Math.seed = ($wbwindow.Math.seed * 9301 + 49297) % 233280;
|
||||||
var rnd = Math.seed / 233280;
|
var rnd = $wbwindow.Math.seed / 233280;
|
||||||
|
|
||||||
return rnd;
|
return rnd;
|
||||||
}
|
}
|
||||||
|
|
||||||
Math.random = seeded_random;
|
$wbwindow.Math.random = seeded_random;
|
||||||
}
|
}
|
||||||
|
|
||||||
function init_crypto_random() {
|
function init_crypto_random() {
|
||||||
@ -687,7 +687,7 @@ var wombat_internal = function($wbwindow) {
|
|||||||
|
|
||||||
var new_getrandom = function(array) {
|
var new_getrandom = function(array) {
|
||||||
for (i = 0; i < array.length; i++) {
|
for (i = 0; i < array.length; i++) {
|
||||||
array[i] = parseInt(Math.random() * 4294967296);
|
array[i] = parseInt($wbwindow.Math.random() * 4294967296);
|
||||||
}
|
}
|
||||||
return array;
|
return array;
|
||||||
}
|
}
|
||||||
@ -931,7 +931,8 @@ var wombat_internal = function($wbwindow) {
|
|||||||
//var timezone = new Date().getTimezoneOffset() * 60 * 1000;
|
//var timezone = new Date().getTimezoneOffset() * 60 * 1000;
|
||||||
// Already UTC!
|
// Already UTC!
|
||||||
var timezone = 0;
|
var timezone = 0;
|
||||||
var timediff = $wbwindow.Date.now() - (timestamp - timezone);
|
var start_now = $wbwindow.Date.now()
|
||||||
|
var timediff = start_now - (timestamp - timezone);
|
||||||
|
|
||||||
if ($wbwindow.__wb_Date_now) {
|
if ($wbwindow.__wb_Date_now) {
|
||||||
return;
|
return;
|
||||||
@ -1656,13 +1657,14 @@ var wombat_internal = function($wbwindow) {
|
|||||||
|
|
||||||
var from = source.WB_wombat_location.origin;
|
var from = source.WB_wombat_location.origin;
|
||||||
|
|
||||||
if (!source.__WB_id) {
|
|
||||||
source.__WB_id = Math.round(Math.random() * 1000) + source.WB_wombat_location.href;
|
|
||||||
}
|
|
||||||
if (!this.__WB_win_id) {
|
if (!this.__WB_win_id) {
|
||||||
this.__WB_win_id = {};
|
this.__WB_win_id = {};
|
||||||
|
this.__WB_counter = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!source.__WB_id) {
|
||||||
|
source.__WB_id = (this.__WB_counter++) + source.WB_wombat_location.href;
|
||||||
|
}
|
||||||
this.__WB_win_id[source.__WB_id] = source;
|
this.__WB_win_id[source.__WB_id] = source;
|
||||||
|
|
||||||
src_id = source.__WB_id;
|
src_id = source.__WB_id;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user