@webrecorder/wombat 3.8.14 → 3.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/make-draft-release.yaml +30 -0
- package/dist/wombat.js +1 -1
- package/dist/wombatWorkers.js +1 -1
- package/package.json +2 -2
- package/src/customStorage.js +6 -7
- package/src/listeners.js +4 -4
- package/src/wombat.js +341 -187
- package/src/wombatWorkers.js +88 -9
package/src/wombat.js
CHANGED
|
@@ -12,7 +12,6 @@ import {
|
|
|
12
12
|
|
|
13
13
|
import { postToGetUrl } from 'warcio/utils';
|
|
14
14
|
|
|
15
|
-
|
|
16
15
|
/**
|
|
17
16
|
* @param {Window} $wbwindow
|
|
18
17
|
* @param {Object} wbinfo
|
|
@@ -62,7 +61,15 @@ function Wombat($wbwindow, wbinfo) {
|
|
|
62
61
|
this.WB_CHECK_THIS_FUNC = '_____WB$wombat$check$this$function_____';
|
|
63
62
|
this.WB_ASSIGN_FUNC = '_____WB$wombat$assign$function_____';
|
|
64
63
|
|
|
65
|
-
this.SKIP_OWN_FUNC_PROPS = [
|
|
64
|
+
this.SKIP_OWN_FUNC_PROPS = [
|
|
65
|
+
'name',
|
|
66
|
+
'length',
|
|
67
|
+
'__WB_is_native_func__',
|
|
68
|
+
'arguments',
|
|
69
|
+
'caller',
|
|
70
|
+
'callee',
|
|
71
|
+
'prototype'
|
|
72
|
+
];
|
|
66
73
|
|
|
67
74
|
this.OVERRIDE_PROPS = [
|
|
68
75
|
'window',
|
|
@@ -277,6 +284,9 @@ function Wombat($wbwindow, wbinfo) {
|
|
|
277
284
|
/** @type {RegExp} */
|
|
278
285
|
this.IP_RX = /^(\d)+\.(\d)+\.(\d)+\.(\d)+$/;
|
|
279
286
|
|
|
287
|
+
/** @type {RegExp} */
|
|
288
|
+
this.REPLACE_MOD = /(\/[\d]*)([\w]+_)(?=\/)/;
|
|
289
|
+
|
|
280
290
|
/** @type {RegExp} */
|
|
281
291
|
this.FullHTMLRegex = /^\s*<(?:html|head|body|frameset|frame|!doctype html)/i;
|
|
282
292
|
|
|
@@ -477,29 +487,33 @@ Wombat.prototype.isString = function(arg) {
|
|
|
477
487
|
return arg != null && Object.getPrototypeOf(arg) === String.prototype;
|
|
478
488
|
};
|
|
479
489
|
|
|
480
|
-
|
|
481
490
|
/**
|
|
482
491
|
* Create blob for content, convert to service-worker based blob URL
|
|
483
492
|
* set iframe to remove blob URL on unload
|
|
484
493
|
*
|
|
485
|
-
*/
|
|
494
|
+
*/
|
|
486
495
|
|
|
487
496
|
Wombat.prototype.blobUrlForIframe = function(iframe, string) {
|
|
488
|
-
var blob = new Blob([string], {type: 'text/html'});
|
|
497
|
+
var blob = new Blob([string], { type: 'text/html' });
|
|
489
498
|
var url = this.URL.createObjectURL(blob);
|
|
490
499
|
var URL = this.URL;
|
|
491
500
|
|
|
492
501
|
iframe.__wb_blobSrc = url;
|
|
493
|
-
iframe.addEventListener(
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
iframe.__wb_blobSrc
|
|
497
|
-
|
|
498
|
-
|
|
502
|
+
iframe.addEventListener(
|
|
503
|
+
'load',
|
|
504
|
+
function() {
|
|
505
|
+
if (iframe.__wb_blobSrc) {
|
|
506
|
+
URL.revokeObjectURL(iframe.__wb_blobSrc);
|
|
507
|
+
iframe.__wb_blobSrc = null;
|
|
508
|
+
}
|
|
509
|
+
},
|
|
510
|
+
{ once: true }
|
|
511
|
+
);
|
|
499
512
|
|
|
500
513
|
iframe.__wb_origSrc = iframe.src;
|
|
501
514
|
var blobIdUrl = url.slice(url.lastIndexOf('/') + 1) + '/' + this.wb_info.url;
|
|
502
|
-
iframe.src =
|
|
515
|
+
iframe.src =
|
|
516
|
+
this.wb_info.prefix + this.wb_info.request_ts + 'mp_/blob:' + blobIdUrl;
|
|
503
517
|
};
|
|
504
518
|
|
|
505
519
|
/**
|
|
@@ -697,7 +711,11 @@ Wombat.prototype.shouldRewriteAttr = function(tagName, attr) {
|
|
|
697
711
|
*/
|
|
698
712
|
Wombat.prototype.skipWrapScriptBasedOnType = function(scriptType) {
|
|
699
713
|
if (!scriptType) return false;
|
|
700
|
-
if (
|
|
714
|
+
if (
|
|
715
|
+
scriptType.indexOf('javascript') >= 0 ||
|
|
716
|
+
scriptType.indexOf('ecmascript') >= 0
|
|
717
|
+
)
|
|
718
|
+
return false;
|
|
701
719
|
if (scriptType.indexOf('json') >= 0) return true;
|
|
702
720
|
if (scriptType.indexOf('text/') >= 0) return true;
|
|
703
721
|
return false;
|
|
@@ -780,7 +798,7 @@ Wombat.prototype.rwModForElement = function(elem, attrName) {
|
|
|
780
798
|
}
|
|
781
799
|
}
|
|
782
800
|
} else if (elem.tagName === 'SCRIPT') {
|
|
783
|
-
return
|
|
801
|
+
return elem.type === 'module' ? 'esm_' : 'js_';
|
|
784
802
|
} else {
|
|
785
803
|
// check if this element has an rewrite modifiers and set mod to it if it does
|
|
786
804
|
var maybeMod = this.tagToMod[elem.tagName];
|
|
@@ -840,7 +858,7 @@ Wombat.prototype.retrieveWBOSRC = function(elem) {
|
|
|
840
858
|
* @return {string}
|
|
841
859
|
*/
|
|
842
860
|
Wombat.prototype.wrapScriptTextJsProxy = function(scriptText, excludes = []) {
|
|
843
|
-
let prefix =
|
|
861
|
+
let prefix =
|
|
844
862
|
'var _____WB$wombat$assign$function_____ = function(name) {return ' +
|
|
845
863
|
'(self._wb_wombat && self._wb_wombat.local_init && self._wb_wombat.local_init(name)) || self[name]; };\n' +
|
|
846
864
|
'if (!self.__WB_pmw) { self.__WB_pmw = function(obj) { ' +
|
|
@@ -854,8 +872,13 @@ Wombat.prototype.wrapScriptTextJsProxy = function(scriptText, excludes = []) {
|
|
|
854
872
|
|
|
855
873
|
prefix += '{\n';
|
|
856
874
|
|
|
857
|
-
scriptText = scriptText.replace(this.IMPORT_JS_CALL,
|
|
858
|
-
|
|
875
|
+
scriptText = scriptText.replace(this.IMPORT_JS_CALL, x =>
|
|
876
|
+
x.replace('import', '____wb_rewrite_import__')
|
|
877
|
+
);
|
|
878
|
+
scriptText = scriptText.replace(
|
|
879
|
+
this.DotPostMessageRe,
|
|
880
|
+
'.__WB_pmw(self.window)$1'
|
|
881
|
+
);
|
|
859
882
|
|
|
860
883
|
return prefix + scriptText + '\n\n}}';
|
|
861
884
|
};
|
|
@@ -949,7 +972,10 @@ Wombat.prototype.resolveRelUrl = function(url, doc) {
|
|
|
949
972
|
if (!doc || !doc.baseURI) {
|
|
950
973
|
return false;
|
|
951
974
|
}
|
|
952
|
-
return (
|
|
975
|
+
return (
|
|
976
|
+
doc.baseURI.startsWith(wombat.HTTPS_PREFIX) ||
|
|
977
|
+
doc.baseURI.startsWith(wombat.HTTP_PREFIX)
|
|
978
|
+
);
|
|
953
979
|
}
|
|
954
980
|
|
|
955
981
|
var baseURI = null;
|
|
@@ -1026,7 +1052,8 @@ Wombat.prototype.extractOriginalURL = function(rewrittenUrl) {
|
|
|
1026
1052
|
|
|
1027
1053
|
if (
|
|
1028
1054
|
url !== rwURLString &&
|
|
1029
|
-
!this.startsWithOneOf(url, this.VALID_PREFIXES) &&
|
|
1055
|
+
!this.startsWithOneOf(url, this.VALID_PREFIXES) &&
|
|
1056
|
+
!this.startsWith(url, 'blob:')
|
|
1030
1057
|
) {
|
|
1031
1058
|
url = this.wb_orig_scheme + url;
|
|
1032
1059
|
}
|
|
@@ -1071,7 +1098,6 @@ Wombat.prototype.makeParser = function(maybeRewrittenURL, doc) {
|
|
|
1071
1098
|
}
|
|
1072
1099
|
|
|
1073
1100
|
return this._makeURLParser(originalURL, docElem);
|
|
1074
|
-
|
|
1075
1101
|
};
|
|
1076
1102
|
|
|
1077
1103
|
Wombat.prototype._makeURLParser = function(url, docElem) {
|
|
@@ -1419,7 +1445,6 @@ Wombat.prototype.defaultProxyGet = function(obj, prop, ownProps, fnCache) {
|
|
|
1419
1445
|
return retVal._WB_wombat_obj_proxy;
|
|
1420
1446
|
} catch (e) {}
|
|
1421
1447
|
}
|
|
1422
|
-
|
|
1423
1448
|
} else if (type === 'function' && ownProps.indexOf(prop) !== -1) {
|
|
1424
1449
|
// certain sites (e.g. facebook) are applying polyfills to native functions
|
|
1425
1450
|
// treating the polyfill as a native function [fn.bind(obj)] causes incorrect execution of the polyfill
|
|
@@ -1461,7 +1486,6 @@ Wombat.prototype.defaultProxyGet = function(obj, prop, ownProps, fnCache) {
|
|
|
1461
1486
|
return boundFn;
|
|
1462
1487
|
}
|
|
1463
1488
|
return cachedFN.boundFn;
|
|
1464
|
-
|
|
1465
1489
|
} else if (type === 'object' && retVal && retVal._WB_wombat_obj_proxy) {
|
|
1466
1490
|
if (retVal instanceof this.WBWindow) {
|
|
1467
1491
|
this.initNewWindowWombat(retVal);
|
|
@@ -1627,7 +1651,6 @@ Wombat.prototype.styleReplacer = function(match, n1, n2, n3, offset, string) {
|
|
|
1627
1651
|
return n1 + this.rewriteUrl(n2) + n3;
|
|
1628
1652
|
};
|
|
1629
1653
|
|
|
1630
|
-
|
|
1631
1654
|
/**
|
|
1632
1655
|
* Due to the fact that we override specific DOM constructors, e.g. Worker,
|
|
1633
1656
|
* the normal TypeErrors are not thrown if the pre-conditions for those
|
|
@@ -1859,10 +1882,7 @@ Wombat.prototype.rewriteUrl_ = function(originalURL, useRel, mod, doc) {
|
|
|
1859
1882
|
// Check for this and add it back in, eg http://localhost/path/ -> http://localhost:8080/path/
|
|
1860
1883
|
if (
|
|
1861
1884
|
this.origHost !== this.origHostname &&
|
|
1862
|
-
this.startsWith(
|
|
1863
|
-
url,
|
|
1864
|
-
this.origProtocol + '//' + this.origHostname + '/'
|
|
1865
|
-
)
|
|
1885
|
+
this.startsWith(url, this.origProtocol + '//' + this.origHostname + '/')
|
|
1866
1886
|
) {
|
|
1867
1887
|
return url.replace(
|
|
1868
1888
|
'/' + this.origHostname + '/',
|
|
@@ -2029,7 +2049,8 @@ Wombat.prototype.performAttributeRewrite = function(
|
|
|
2029
2049
|
return value;
|
|
2030
2050
|
}
|
|
2031
2051
|
var mod = this.rwModForElement(elem, name);
|
|
2032
|
-
if (
|
|
2052
|
+
if (
|
|
2053
|
+
elem &&
|
|
2033
2054
|
this.wbUseAFWorker &&
|
|
2034
2055
|
this.WBAutoFetchWorker &&
|
|
2035
2056
|
this.isSavedDataSrcSrcset(elem)
|
|
@@ -2039,7 +2060,7 @@ Wombat.prototype.performAttributeRewrite = function(
|
|
|
2039
2060
|
var result = this.rewriteUrl(value, false, mod, ownerDoc);
|
|
2040
2061
|
if (mod === 'esm_' && result && result.indexOf('esm_/') < 0) {
|
|
2041
2062
|
// replace current modifier with esm_ if already rewritten
|
|
2042
|
-
result = result.replace(
|
|
2063
|
+
result = result.replace(this.REPLACE_MOD, '$1esm_');
|
|
2043
2064
|
}
|
|
2044
2065
|
return result;
|
|
2045
2066
|
};
|
|
@@ -2053,7 +2074,13 @@ Wombat.prototype.performAttributeRewrite = function(
|
|
|
2053
2074
|
*/
|
|
2054
2075
|
Wombat.prototype.rewriteAttr = function(elem, name, absUrlOnly) {
|
|
2055
2076
|
var changed = false;
|
|
2056
|
-
if (
|
|
2077
|
+
if (
|
|
2078
|
+
!elem ||
|
|
2079
|
+
!elem.getAttribute ||
|
|
2080
|
+
elem._no_rewrite ||
|
|
2081
|
+
elem['_' + name] ||
|
|
2082
|
+
(elem.tagName && elem.tagName.indexOf('-') > 0)
|
|
2083
|
+
) {
|
|
2057
2084
|
return changed;
|
|
2058
2085
|
}
|
|
2059
2086
|
|
|
@@ -2061,7 +2088,13 @@ Wombat.prototype.rewriteAttr = function(elem, name, absUrlOnly) {
|
|
|
2061
2088
|
|
|
2062
2089
|
if (!value || this.startsWith(value, 'javascript:')) return changed;
|
|
2063
2090
|
|
|
2064
|
-
var new_value = this.performAttributeRewrite(
|
|
2091
|
+
var new_value = this.performAttributeRewrite(
|
|
2092
|
+
elem,
|
|
2093
|
+
name,
|
|
2094
|
+
value,
|
|
2095
|
+
elem.ownerDocument,
|
|
2096
|
+
absUrlOnly
|
|
2097
|
+
);
|
|
2065
2098
|
|
|
2066
2099
|
if (new_value !== value) {
|
|
2067
2100
|
this.removeWBOSRC(elem);
|
|
@@ -2345,7 +2378,10 @@ Wombat.prototype.rewriteElem = function(elem) {
|
|
|
2345
2378
|
if (!src) {
|
|
2346
2379
|
elem.__WB_blank = true;
|
|
2347
2380
|
}
|
|
2348
|
-
elem.src =
|
|
2381
|
+
elem.src =
|
|
2382
|
+
this.wb_info.prefix +
|
|
2383
|
+
this.wb_info.request_ts +
|
|
2384
|
+
'mp_/about:blank';
|
|
2349
2385
|
}
|
|
2350
2386
|
}
|
|
2351
2387
|
}
|
|
@@ -2383,7 +2419,7 @@ Wombat.prototype.rewriteElem = function(elem) {
|
|
|
2383
2419
|
}
|
|
2384
2420
|
}
|
|
2385
2421
|
|
|
2386
|
-
if (elem.hasAttribute && elem.removeAttribute) {
|
|
2422
|
+
if (elem.hasAttribute && elem.removeAttribute && !elem._no_rewrite) {
|
|
2387
2423
|
if (elem.hasAttribute('crossorigin')) {
|
|
2388
2424
|
elem.removeAttribute('crossorigin');
|
|
2389
2425
|
changed = true;
|
|
@@ -2523,10 +2559,13 @@ Wombat.prototype.rewriteHtml = function(string, checkEndTag) {
|
|
|
2523
2559
|
!this.endsWith(rwString.toLowerCase(), end_tag)
|
|
2524
2560
|
) {
|
|
2525
2561
|
new_html = new_html.substring(0, new_html.length - end_tag.length);
|
|
2526
|
-
|
|
2527
|
-
|
|
2528
|
-
|
|
2529
|
-
} else if (
|
|
2562
|
+
// similarly, check if original had extra ending tags that rewritten did not
|
|
2563
|
+
// eg. <a>...</a></div> rewritten to <a>...</a>, then we add the remaining </div>
|
|
2564
|
+
// currently only works with different tags
|
|
2565
|
+
} else if (
|
|
2566
|
+
new_html.trimEnd().endsWith(end_tag) &&
|
|
2567
|
+
!rwString.trimEnd().endsWith(end_tag)
|
|
2568
|
+
) {
|
|
2530
2569
|
var lastInx = rwString.lastIndexOf(end_tag);
|
|
2531
2570
|
if (lastInx > 0) {
|
|
2532
2571
|
new_html += rwString.slice(lastInx + end_tag.length);
|
|
@@ -2683,8 +2722,12 @@ Wombat.prototype.rewriteWorker = function(workerUrl, opts) {
|
|
|
2683
2722
|
workerUrl = workerUrl.toString();
|
|
2684
2723
|
var isBlob = workerUrl.indexOf('blob:') === 0;
|
|
2685
2724
|
var isJS = workerUrl.indexOf('javascript:') === 0;
|
|
2686
|
-
var
|
|
2725
|
+
var isModule = opts && opts.type === 'module';
|
|
2726
|
+
var mod = isModule ? 'wkrm_' : 'wkr_';
|
|
2687
2727
|
if (!isBlob && !isJS) {
|
|
2728
|
+
if (this.startsWithOneOf(workerUrl, this.wb_prefixes)) {
|
|
2729
|
+
return workerUrl.replace(this.REPLACE_MOD, '$1' + mod);
|
|
2730
|
+
}
|
|
2688
2731
|
if (
|
|
2689
2732
|
!this.startsWithOneOf(workerUrl, this.VALID_PREFIXES) &&
|
|
2690
2733
|
!this.startsWith(workerUrl, '/') &&
|
|
@@ -2867,7 +2910,10 @@ Wombat.prototype.rewriteSetTimeoutInterval = function(
|
|
|
2867
2910
|
Wombat.prototype.rewriteHTMLAssign = function(thisObj, oSetter, newValue) {
|
|
2868
2911
|
var res = newValue;
|
|
2869
2912
|
var tagName = thisObj.tagName;
|
|
2870
|
-
if (
|
|
2913
|
+
if (
|
|
2914
|
+
!thisObj._no_rewrite &&
|
|
2915
|
+
!(thisObj instanceof this.$wbwindow.HTMLTemplateElement)
|
|
2916
|
+
) {
|
|
2871
2917
|
if (tagName === 'STYLE') {
|
|
2872
2918
|
res = this.rewriteStyle(newValue);
|
|
2873
2919
|
} else if (tagName === 'SCRIPT') {
|
|
@@ -2911,13 +2957,21 @@ Wombat.prototype.rewriteHTMLAssign = function(thisObj, oSetter, newValue) {
|
|
|
2911
2957
|
* @param {*} evalArg
|
|
2912
2958
|
* @return {*}
|
|
2913
2959
|
*/
|
|
2914
|
-
Wombat.prototype.rewriteEvalArg = function(
|
|
2915
|
-
|
|
2960
|
+
Wombat.prototype.rewriteEvalArg = function(
|
|
2961
|
+
rawEvalOrWrapper,
|
|
2962
|
+
evalArg,
|
|
2963
|
+
extraArg
|
|
2964
|
+
) {
|
|
2965
|
+
if (
|
|
2966
|
+
this.$wbwindow.TrustedScript &&
|
|
2967
|
+
evalArg instanceof this.$wbwindow.TrustedScript
|
|
2968
|
+
) {
|
|
2916
2969
|
evalArg = evalArg.toString();
|
|
2917
2970
|
}
|
|
2918
2971
|
var excludes = [];
|
|
2919
2972
|
var toBeEvald =
|
|
2920
|
-
this.isString(evalArg) &&
|
|
2973
|
+
this.isString(evalArg) &&
|
|
2974
|
+
!this.skipWrapScriptTextBasedOnText(evalArg, excludes)
|
|
2921
2975
|
? this.wrapScriptTextJsProxy(evalArg, excludes)
|
|
2922
2976
|
: this.otherEvalRewrite(evalArg);
|
|
2923
2977
|
return rawEvalOrWrapper(toBeEvald, extraArg);
|
|
@@ -2930,7 +2984,7 @@ Wombat.prototype.rewriteEvalArg = function(rawEvalOrWrapper, evalArg, extraArg)
|
|
|
2930
2984
|
*/
|
|
2931
2985
|
|
|
2932
2986
|
Wombat.prototype.otherEvalRewrite = function(value) {
|
|
2933
|
-
if (typeof
|
|
2987
|
+
if (typeof value !== 'string') {
|
|
2934
2988
|
return value;
|
|
2935
2989
|
}
|
|
2936
2990
|
return value.replace(this.IMPORT_JS_REGEX, this.styleReplacer);
|
|
@@ -3032,7 +3086,11 @@ Wombat.prototype.overrideAttr = function(obj, attr, mod) {
|
|
|
3032
3086
|
wombat.removeWBOSRC(this);
|
|
3033
3087
|
}
|
|
3034
3088
|
}
|
|
3035
|
-
var val = wombat.rewriteUrl(
|
|
3089
|
+
var val = wombat.rewriteUrl(
|
|
3090
|
+
orig,
|
|
3091
|
+
false,
|
|
3092
|
+
this.type === 'module' ? 'esm_' : mod
|
|
3093
|
+
);
|
|
3036
3094
|
if (orig_setter) {
|
|
3037
3095
|
return orig_setter.call(this, val);
|
|
3038
3096
|
} else if (wombat.wb_setAttribute) {
|
|
@@ -3067,7 +3125,7 @@ Wombat.prototype.overridePropExtract = function(proto, prop) {
|
|
|
3067
3125
|
var orig_getter = this.getOrigGetter(proto, prop);
|
|
3068
3126
|
var wombat = this;
|
|
3069
3127
|
if (orig_getter) {
|
|
3070
|
-
var new_getter = function
|
|
3128
|
+
var new_getter = function() {
|
|
3071
3129
|
var obj = wombat.proxyToObj(this);
|
|
3072
3130
|
var res = orig_getter.call(obj);
|
|
3073
3131
|
if (obj.__WB_no_unrewrite) {
|
|
@@ -3090,16 +3148,16 @@ Wombat.prototype.overrideDeProxyPropAssign = function(proto, prop) {
|
|
|
3090
3148
|
var orig_getter = this.getOrigGetter(proto, prop);
|
|
3091
3149
|
var wombat = this;
|
|
3092
3150
|
if (orig_setter) {
|
|
3093
|
-
var new_setter = function
|
|
3094
|
-
return orig_setter.call(
|
|
3151
|
+
var new_setter = function(value) {
|
|
3152
|
+
return orig_setter.call(
|
|
3153
|
+
wombat.proxyToObj(this),
|
|
3154
|
+
wombat.proxyToObj(value)
|
|
3155
|
+
);
|
|
3095
3156
|
};
|
|
3096
3157
|
this.defProp(proto, prop, new_setter, orig_getter);
|
|
3097
3158
|
}
|
|
3098
3159
|
};
|
|
3099
3160
|
|
|
3100
|
-
|
|
3101
|
-
|
|
3102
|
-
|
|
3103
3161
|
/**
|
|
3104
3162
|
* Overrides referrer -- if top-replay frame, referrer should be "", otherwise extractOriginURL
|
|
3105
3163
|
* @param {Object} proto
|
|
@@ -3128,7 +3186,6 @@ Wombat.prototype.overrideReferrer = function($document) {
|
|
|
3128
3186
|
}
|
|
3129
3187
|
};
|
|
3130
3188
|
|
|
3131
|
-
|
|
3132
3189
|
/**
|
|
3133
3190
|
* Applies an attribute getter override IFF an original getter exists that
|
|
3134
3191
|
* ensures that the results of retrieving the attributes value is not a
|
|
@@ -3239,7 +3296,7 @@ Wombat.prototype.overrideStyleAttr = function(obj, attr, propName) {
|
|
|
3239
3296
|
|
|
3240
3297
|
var getter = orig_getter;
|
|
3241
3298
|
|
|
3242
|
-
var extractUrl = function
|
|
3299
|
+
var extractUrl = function(_, p1, p2, p3, p4) {
|
|
3243
3300
|
return p1 + (p2 || '') + wombat.extractOriginalURL(p3) + p4;
|
|
3244
3301
|
};
|
|
3245
3302
|
|
|
@@ -3379,7 +3436,6 @@ Wombat.prototype.overrideHtmlAssignSrcDoc = function(elem, prop) {
|
|
|
3379
3436
|
this.defProp(obj, prop, setter, getter);
|
|
3380
3437
|
};
|
|
3381
3438
|
|
|
3382
|
-
|
|
3383
3439
|
/**
|
|
3384
3440
|
* Override .dataset attribute on element and wraps in a proxy that unrewrites URLs
|
|
3385
3441
|
*/
|
|
@@ -3394,10 +3450,12 @@ Wombat.prototype.overrideDataSet = function() {
|
|
|
3394
3450
|
|
|
3395
3451
|
var proxy = new Proxy(dataset, {
|
|
3396
3452
|
get(target, prop, receiver) {
|
|
3397
|
-
|
|
3398
3453
|
var result = target[prop];
|
|
3399
3454
|
|
|
3400
|
-
if (
|
|
3455
|
+
if (
|
|
3456
|
+
typeof result === 'string' &&
|
|
3457
|
+
wombat.startsWithOneOf(result, wombat.wb_prefixes)
|
|
3458
|
+
) {
|
|
3401
3459
|
return wombat.extractOriginalURL(result);
|
|
3402
3460
|
}
|
|
3403
3461
|
|
|
@@ -3411,7 +3469,6 @@ Wombat.prototype.overrideDataSet = function() {
|
|
|
3411
3469
|
this.defProp(obj, 'dataset', null, getter);
|
|
3412
3470
|
};
|
|
3413
3471
|
|
|
3414
|
-
|
|
3415
3472
|
/**
|
|
3416
3473
|
* Override .style attribute on element and wraps in a proxy that unrewrites URLs
|
|
3417
3474
|
*/
|
|
@@ -3440,7 +3497,10 @@ Wombat.prototype.overrideStyleProxy = function(overrideProps) {
|
|
|
3440
3497
|
get(target, prop, receiver) {
|
|
3441
3498
|
var value = target[prop];
|
|
3442
3499
|
|
|
3443
|
-
if (
|
|
3500
|
+
if (
|
|
3501
|
+
typeof value === 'function' &&
|
|
3502
|
+
(prop === 'setProperty' || wombat.isNativeFunction(value))
|
|
3503
|
+
) {
|
|
3444
3504
|
if (!fnCache[prop]) {
|
|
3445
3505
|
fnCache[prop] = value.bind(style);
|
|
3446
3506
|
}
|
|
@@ -3448,7 +3508,7 @@ Wombat.prototype.overrideStyleProxy = function(overrideProps) {
|
|
|
3448
3508
|
}
|
|
3449
3509
|
|
|
3450
3510
|
return value;
|
|
3451
|
-
}
|
|
3511
|
+
}
|
|
3452
3512
|
});
|
|
3453
3513
|
|
|
3454
3514
|
return proxy;
|
|
@@ -3457,8 +3517,6 @@ Wombat.prototype.overrideStyleProxy = function(overrideProps) {
|
|
|
3457
3517
|
this.defProp(obj, 'style', orig_setter, getter);
|
|
3458
3518
|
};
|
|
3459
3519
|
|
|
3460
|
-
|
|
3461
|
-
|
|
3462
3520
|
/**
|
|
3463
3521
|
* Overrides the getter and setter functions for the supplied property
|
|
3464
3522
|
* on the HTMLIFrameElement
|
|
@@ -3488,33 +3546,40 @@ Wombat.prototype.overrideIframeContentAccess = function(prop) {
|
|
|
3488
3546
|
obj['_get_' + prop] = orig_getter;
|
|
3489
3547
|
};
|
|
3490
3548
|
|
|
3491
|
-
|
|
3492
3549
|
Wombat.prototype.overrideSWAccess = function($wbwindow) {
|
|
3493
|
-
if (
|
|
3550
|
+
if (
|
|
3551
|
+
!$wbwindow.navigator.serviceWorker ||
|
|
3552
|
+
!$wbwindow.navigator.serviceWorker.controller
|
|
3553
|
+
) {
|
|
3494
3554
|
return;
|
|
3495
3555
|
}
|
|
3496
3556
|
|
|
3497
3557
|
$wbwindow._WB_wombat_sw = $wbwindow.navigator.serviceWorker;
|
|
3498
3558
|
|
|
3499
|
-
|
|
3500
3559
|
var overrideSW = {
|
|
3501
|
-
|
|
3502
|
-
|
|
3503
|
-
|
|
3504
|
-
|
|
3505
|
-
|
|
3506
|
-
|
|
3507
|
-
|
|
3508
|
-
|
|
3509
|
-
|
|
3510
|
-
|
|
3511
|
-
|
|
3560
|
+
controller: null,
|
|
3561
|
+
ready: Promise.resolve({ unregister: function() {} }),
|
|
3562
|
+
register: function() {
|
|
3563
|
+
return Promise.reject();
|
|
3564
|
+
},
|
|
3565
|
+
addEventListener: function() {},
|
|
3566
|
+
removeEventListener: function() {},
|
|
3567
|
+
onmessage: null,
|
|
3568
|
+
oncontrollerchange: null,
|
|
3569
|
+
getRegistrations: function() {
|
|
3570
|
+
return Promise.resolve([]);
|
|
3571
|
+
},
|
|
3572
|
+
getRegistration: function() {
|
|
3573
|
+
return Promise.resolve(undefined);
|
|
3574
|
+
},
|
|
3575
|
+
startMessages: function() {}
|
|
3576
|
+
};
|
|
3512
3577
|
|
|
3513
|
-
this.defGetterProp($wbwindow.navigator, 'serviceWorker', function() {
|
|
3578
|
+
this.defGetterProp($wbwindow.navigator, 'serviceWorker', function() {
|
|
3579
|
+
return overrideSW;
|
|
3580
|
+
});
|
|
3514
3581
|
};
|
|
3515
3582
|
|
|
3516
|
-
|
|
3517
|
-
|
|
3518
3583
|
/**
|
|
3519
3584
|
* Overrides the supplied method in order to ensure that the `this` argument
|
|
3520
3585
|
* of the function is not one of the JS Proxy objects used by wombat.
|
|
@@ -3585,7 +3650,10 @@ Wombat.prototype.overrideFunctionApply = function($wbwindow) {
|
|
|
3585
3650
|
return;
|
|
3586
3651
|
}
|
|
3587
3652
|
var orig_apply = $wbwindow.Function.prototype.apply;
|
|
3588
|
-
$wbwindow.Function.prototype
|
|
3653
|
+
Object.defineProperty($wbwindow.Function.prototype, '__WB_orig_apply', {
|
|
3654
|
+
value: orig_apply,
|
|
3655
|
+
enumarable: false
|
|
3656
|
+
});
|
|
3589
3657
|
var wombat = this;
|
|
3590
3658
|
$wbwindow.Function.prototype.apply = function apply(obj, args) {
|
|
3591
3659
|
// if native function, de-proxy
|
|
@@ -3600,7 +3668,6 @@ Wombat.prototype.overrideFunctionApply = function($wbwindow) {
|
|
|
3600
3668
|
this.wb_funToString.apply = orig_apply;
|
|
3601
3669
|
};
|
|
3602
3670
|
|
|
3603
|
-
|
|
3604
3671
|
/**
|
|
3605
3672
|
* Overrides Function.prototype.call in order to ensure that none of the
|
|
3606
3673
|
* arguments of `native` functions are one of the JS Proxy objects used by wombat.
|
|
@@ -3611,7 +3678,10 @@ Wombat.prototype.overrideFunctionCall = function($wbwindow) {
|
|
|
3611
3678
|
return;
|
|
3612
3679
|
}
|
|
3613
3680
|
var orig_call = $wbwindow.Function.prototype.call;
|
|
3614
|
-
$wbwindow.Function.prototype
|
|
3681
|
+
Object.defineProperty($wbwindow.Function.prototype, '__WB_orig_call', {
|
|
3682
|
+
value: orig_call,
|
|
3683
|
+
enumarable: false
|
|
3684
|
+
});
|
|
3615
3685
|
var wombat = this;
|
|
3616
3686
|
$wbwindow.Function.prototype.call = function call(obj, ...args) {
|
|
3617
3687
|
// if native function, de-proxy
|
|
@@ -3635,19 +3705,21 @@ Wombat.prototype.overrideFunctionBind = function($wbwindow) {
|
|
|
3635
3705
|
return;
|
|
3636
3706
|
}
|
|
3637
3707
|
var orig_bind = $wbwindow.Function.prototype.bind;
|
|
3638
|
-
$wbwindow.Function.prototype
|
|
3708
|
+
Object.defineProperty($wbwindow.Function.prototype, '__WB_orig_bind', {
|
|
3709
|
+
value: orig_bind,
|
|
3710
|
+
enumarable: false
|
|
3711
|
+
});
|
|
3639
3712
|
var wombat = this;
|
|
3640
3713
|
$wbwindow.Function.prototype.bind = function bind(obj) {
|
|
3641
3714
|
var isNative = wombat.isNativeFunction(this);
|
|
3642
|
-
var result = isNative
|
|
3715
|
+
var result = isNative
|
|
3716
|
+
? this.__WB_orig_bind.apply(this, arguments)
|
|
3717
|
+
: this.__WB_orig_bind.__WB_orig_apply(this, arguments);
|
|
3643
3718
|
result.__WB_is_native_func__ = isNative;
|
|
3644
3719
|
return result;
|
|
3645
3720
|
};
|
|
3646
3721
|
};
|
|
3647
3722
|
|
|
3648
|
-
|
|
3649
|
-
|
|
3650
|
-
|
|
3651
3723
|
/**
|
|
3652
3724
|
* Overrides the getter and setter functions for the `srcset` property
|
|
3653
3725
|
* of the supplied Object in order to rewrite accesses and retrievals
|
|
@@ -4017,15 +4089,15 @@ Wombat.prototype.initAttrOverrides = function() {
|
|
|
4017
4089
|
var style_proto = this.$wbwindow.CSSStyleDeclaration.prototype;
|
|
4018
4090
|
|
|
4019
4091
|
var cssAttrToProps = {
|
|
4020
|
-
|
|
4021
|
-
|
|
4022
|
-
|
|
4023
|
-
|
|
4024
|
-
|
|
4025
|
-
|
|
4026
|
-
|
|
4027
|
-
|
|
4028
|
-
|
|
4092
|
+
background: 'background',
|
|
4093
|
+
backgroundImage: 'background-image',
|
|
4094
|
+
cursor: 'cursor',
|
|
4095
|
+
listStyle: 'list-style',
|
|
4096
|
+
listStyleImage: 'list-style-image',
|
|
4097
|
+
border: 'border',
|
|
4098
|
+
borderImage: 'border-image',
|
|
4099
|
+
borderImageSource: 'border-image-source',
|
|
4100
|
+
maskImage: 'mask-image'
|
|
4029
4101
|
};
|
|
4030
4102
|
|
|
4031
4103
|
this.overrideStyleProxy(Object.values(cssAttrToProps));
|
|
@@ -4294,7 +4366,6 @@ Wombat.prototype.initDateOverride = function(timestamp) {
|
|
|
4294
4366
|
});
|
|
4295
4367
|
};
|
|
4296
4368
|
|
|
4297
|
-
|
|
4298
4369
|
Wombat.prototype.initBlobOverride = function() {
|
|
4299
4370
|
// don't use for SW replay as blob: iframes won't have access to SW
|
|
4300
4371
|
if (!this.$wbwindow.Blob || this.wb_info.isSW) {
|
|
@@ -4307,10 +4378,17 @@ Wombat.prototype.initBlobOverride = function() {
|
|
|
4307
4378
|
|
|
4308
4379
|
this.$wbwindow.Blob = (function(Blob_) {
|
|
4309
4380
|
return function Blob(array, options) {
|
|
4310
|
-
|
|
4311
|
-
|
|
4381
|
+
if (
|
|
4382
|
+
options &&
|
|
4383
|
+
(options.type === 'application/xhtml+xml' ||
|
|
4384
|
+
options.type === 'text/html')
|
|
4385
|
+
) {
|
|
4312
4386
|
// for now, just handle single string case
|
|
4313
|
-
if (
|
|
4387
|
+
if (
|
|
4388
|
+
array.length === 1 &&
|
|
4389
|
+
typeof array[0] === 'string' &&
|
|
4390
|
+
wombat.startsWith(array[0], '<!DOCTYPE html>')
|
|
4391
|
+
) {
|
|
4314
4392
|
array[0] = wombat.rewriteHtml(array[0]);
|
|
4315
4393
|
options.type = 'text/html';
|
|
4316
4394
|
}
|
|
@@ -4336,14 +4414,17 @@ Wombat.prototype.initIntersectionObsOverride = function() {
|
|
|
4336
4414
|
|
|
4337
4415
|
return new IObs(callback, options);
|
|
4338
4416
|
};
|
|
4339
|
-
|
|
4340
4417
|
})(this.$wbwindow.IntersectionObserver);
|
|
4341
4418
|
|
|
4342
4419
|
this.$wbwindow.IntersectionObserver.prototype = orig_iobs.prototype;
|
|
4343
4420
|
|
|
4344
|
-
Object.defineProperty(
|
|
4345
|
-
|
|
4346
|
-
|
|
4421
|
+
Object.defineProperty(
|
|
4422
|
+
this.$wbwindow.IntersectionObserver.prototype,
|
|
4423
|
+
'constructor',
|
|
4424
|
+
{
|
|
4425
|
+
value: this.$wbwindow.IntersectionObserver
|
|
4426
|
+
}
|
|
4427
|
+
);
|
|
4347
4428
|
};
|
|
4348
4429
|
|
|
4349
4430
|
Wombat.prototype.initWSOverride = function() {
|
|
@@ -4396,7 +4477,7 @@ Wombat.prototype.initWSOverride = function() {
|
|
|
4396
4477
|
|
|
4397
4478
|
addToStringTagToClass(this.$wbwindow.WebSocket, 'WebSocket');
|
|
4398
4479
|
};
|
|
4399
|
-
|
|
4480
|
+
|
|
4400
4481
|
/**
|
|
4401
4482
|
* Applies an override to the document.title property in order to ensure
|
|
4402
4483
|
* that actual top (archive top frame containing the replay iframe) receives
|
|
@@ -4541,7 +4622,8 @@ Wombat.prototype.initCookiePreset = function() {
|
|
|
4541
4622
|
if (this.wb_info.presetCookie) {
|
|
4542
4623
|
var splitCookies = this.wb_info.presetCookie.split(';');
|
|
4543
4624
|
for (var i = 0; i < splitCookies.length; i++) {
|
|
4544
|
-
this.$wbwindow.document.cookie =
|
|
4625
|
+
this.$wbwindow.document.cookie =
|
|
4626
|
+
splitCookies[i].trim() + '; Path=' + this.rewriteUrl('./', true);
|
|
4545
4627
|
}
|
|
4546
4628
|
}
|
|
4547
4629
|
};
|
|
@@ -4564,8 +4646,11 @@ Wombat.prototype.initCookiePreset = function() {
|
|
|
4564
4646
|
Wombat.prototype.initHTTPOverrides = function() {
|
|
4565
4647
|
var wombat = this;
|
|
4566
4648
|
|
|
4567
|
-
|
|
4568
|
-
this.overridePropExtract(
|
|
4649
|
+
// responseURL override
|
|
4650
|
+
this.overridePropExtract(
|
|
4651
|
+
this.$wbwindow.XMLHttpRequest.prototype,
|
|
4652
|
+
'responseURL'
|
|
4653
|
+
);
|
|
4569
4654
|
|
|
4570
4655
|
var convertToGet = !!this.wb_info.convert_post_to_get;
|
|
4571
4656
|
|
|
@@ -4592,7 +4677,8 @@ Wombat.prototype.initHTTPOverrides = function() {
|
|
|
4592
4677
|
}
|
|
4593
4678
|
} else {
|
|
4594
4679
|
var origOpen = this.$wbwindow.XMLHttpRequest.prototype.open;
|
|
4595
|
-
var origSetRequestHeader = this.$wbwindow.XMLHttpRequest.prototype
|
|
4680
|
+
var origSetRequestHeader = this.$wbwindow.XMLHttpRequest.prototype
|
|
4681
|
+
.setRequestHeader;
|
|
4596
4682
|
var origSend = this.$wbwindow.XMLHttpRequest.prototype.send;
|
|
4597
4683
|
this.utilFns.XHRopen = origOpen;
|
|
4598
4684
|
this.utilFns.XHRsend = origSend;
|
|
@@ -4604,18 +4690,24 @@ Wombat.prototype.initHTTPOverrides = function() {
|
|
|
4604
4690
|
|
|
4605
4691
|
this.$wbwindow.XMLHttpRequest.prototype.setAttributionReporting = function() {};
|
|
4606
4692
|
|
|
4607
|
-
this.$wbwindow.XMLHttpRequest.prototype.setRequestHeader = function(
|
|
4693
|
+
this.$wbwindow.XMLHttpRequest.prototype.setRequestHeader = function(
|
|
4694
|
+
name,
|
|
4695
|
+
value
|
|
4696
|
+
) {
|
|
4608
4697
|
this.__WB_xhr_headers.set(name, value);
|
|
4609
4698
|
};
|
|
4610
4699
|
|
|
4611
4700
|
this.$wbwindow.XMLHttpRequest.prototype.send = async function(value) {
|
|
4612
|
-
if (
|
|
4613
|
-
|
|
4701
|
+
if (
|
|
4702
|
+
convertToGet &&
|
|
4703
|
+
(this.__WB_xhr_open_arguments[0] === 'POST' ||
|
|
4704
|
+
this.__WB_xhr_open_arguments[0] === 'PUT')
|
|
4705
|
+
) {
|
|
4614
4706
|
var request = {
|
|
4615
|
-
|
|
4616
|
-
|
|
4617
|
-
|
|
4618
|
-
|
|
4707
|
+
url: this.__WB_xhr_open_arguments[1],
|
|
4708
|
+
method: this.__WB_xhr_open_arguments[0],
|
|
4709
|
+
headers: this.__WB_xhr_headers,
|
|
4710
|
+
postData: value
|
|
4619
4711
|
};
|
|
4620
4712
|
|
|
4621
4713
|
if (postToGetUrl(request)) {
|
|
@@ -4628,13 +4720,21 @@ Wombat.prototype.initHTTPOverrides = function() {
|
|
|
4628
4720
|
// sync mode: disable unless Firefox
|
|
4629
4721
|
// sync xhr with service workers supported only in FF at the moment
|
|
4630
4722
|
// https://wpt.fyi/results/service-workers/service-worker/fetch-request-xhr-sync.https.html
|
|
4631
|
-
if (
|
|
4723
|
+
if (
|
|
4724
|
+
this.__WB_xhr_open_arguments.length > 2 &&
|
|
4725
|
+
!this.__WB_xhr_open_arguments[2] &&
|
|
4726
|
+
navigator.userAgent.indexOf('Firefox') === -1
|
|
4727
|
+
) {
|
|
4632
4728
|
this.__WB_xhr_open_arguments[2] = true;
|
|
4633
|
-
console.warn(
|
|
4729
|
+
console.warn(
|
|
4730
|
+
'wombat.js: Sync XHR not supported in SW-based replay in this browser, converted to async'
|
|
4731
|
+
);
|
|
4634
4732
|
}
|
|
4635
4733
|
|
|
4636
4734
|
if (!this._no_rewrite) {
|
|
4637
|
-
this.__WB_xhr_open_arguments[1] = wombat.rewriteUrl(
|
|
4735
|
+
this.__WB_xhr_open_arguments[1] = wombat.rewriteUrl(
|
|
4736
|
+
this.__WB_xhr_open_arguments[1]
|
|
4737
|
+
);
|
|
4638
4738
|
}
|
|
4639
4739
|
|
|
4640
4740
|
origOpen.apply(this, this.__WB_xhr_open_arguments);
|
|
@@ -4644,7 +4744,11 @@ Wombat.prototype.initHTTPOverrides = function() {
|
|
|
4644
4744
|
origSetRequestHeader.call(this, name, value);
|
|
4645
4745
|
}
|
|
4646
4746
|
|
|
4647
|
-
origSetRequestHeader.call(
|
|
4747
|
+
origSetRequestHeader.call(
|
|
4748
|
+
this,
|
|
4749
|
+
'X-Pywb-Requested-With',
|
|
4750
|
+
'XMLHttpRequest'
|
|
4751
|
+
);
|
|
4648
4752
|
}
|
|
4649
4753
|
|
|
4650
4754
|
return origSend.call(this, value);
|
|
@@ -4801,7 +4905,10 @@ Wombat.prototype.initElementGetSetAttributeOverride = function() {
|
|
|
4801
4905
|
rwValue = wombat.rewriteInlineStyle(value);
|
|
4802
4906
|
} else if (lowername === 'style') {
|
|
4803
4907
|
rwValue = wombat.rewriteStyle(value);
|
|
4804
|
-
} else if (
|
|
4908
|
+
} else if (
|
|
4909
|
+
lowername === 'srcset' ||
|
|
4910
|
+
(lowername === 'imagesrcset' && this.tagName === 'LINK')
|
|
4911
|
+
) {
|
|
4805
4912
|
rwValue = wombat.rewriteSrcset(value, this);
|
|
4806
4913
|
} else {
|
|
4807
4914
|
var shouldRW = wombat.shouldRewriteAttr(this.tagName, lowername);
|
|
@@ -4938,9 +5045,12 @@ Wombat.prototype.initQuerySelectorOverride = function() {
|
|
|
4938
5045
|
}
|
|
4939
5046
|
|
|
4940
5047
|
function rewriteQuery(query) {
|
|
4941
|
-
if (typeof
|
|
5048
|
+
if (typeof query === 'string') {
|
|
4942
5049
|
try {
|
|
4943
|
-
query = query.replace(
|
|
5050
|
+
query = query.replace(
|
|
5051
|
+
/((?:^|\s)\b\w+\[(?:src|href|data-href))[\^]?(=['"]?(?:https?[:])?\/\/)/,
|
|
5052
|
+
'$1*$2'
|
|
5053
|
+
);
|
|
4944
5054
|
} catch (e) {
|
|
4945
5055
|
// ignore
|
|
4946
5056
|
}
|
|
@@ -4954,19 +5064,13 @@ Wombat.prototype.initQuerySelectorOverride = function() {
|
|
|
4954
5064
|
var orig_QS = this.$wbwindow.document.querySelector;
|
|
4955
5065
|
|
|
4956
5066
|
var querySelector = function(query) {
|
|
4957
|
-
return orig_QS.call(
|
|
4958
|
-
wombat.proxyToObj(this),
|
|
4959
|
-
rewriteQuery(query)
|
|
4960
|
-
);
|
|
5067
|
+
return orig_QS.call(wombat.proxyToObj(this), rewriteQuery(query));
|
|
4961
5068
|
};
|
|
4962
5069
|
|
|
4963
5070
|
var orig_QSA = this.$wbwindow.document.querySelectorAll;
|
|
4964
5071
|
|
|
4965
5072
|
var querySelectorAll = function(query) {
|
|
4966
|
-
return orig_QSA.call(
|
|
4967
|
-
wombat.proxyToObj(this),
|
|
4968
|
-
rewriteQuery(query)
|
|
4969
|
-
);
|
|
5073
|
+
return orig_QSA.call(wombat.proxyToObj(this), rewriteQuery(query));
|
|
4970
5074
|
};
|
|
4971
5075
|
|
|
4972
5076
|
this.$wbwindow.Document.prototype.querySelector = querySelector;
|
|
@@ -4976,8 +5080,6 @@ Wombat.prototype.initQuerySelectorOverride = function() {
|
|
|
4976
5080
|
this.$wbwindow.document.querySelectorAll = querySelectorAll;
|
|
4977
5081
|
};
|
|
4978
5082
|
|
|
4979
|
-
|
|
4980
|
-
|
|
4981
5083
|
/**
|
|
4982
5084
|
* Applies an override to Element.insertAdjacentHTML in order to ensure
|
|
4983
5085
|
* that the strings of HTML to be inserted are rewritten and to
|
|
@@ -5162,12 +5264,20 @@ Wombat.prototype.initDocWriteOpenCloseOverride = function() {
|
|
|
5162
5264
|
var thisObj = wombat.proxyToObj(fnThis);
|
|
5163
5265
|
|
|
5164
5266
|
if (fnThis.readyState === 'loading') {
|
|
5165
|
-
|
|
5267
|
+
// skip if seems to be part of an open comment
|
|
5268
|
+
// if an open comment exists after end of comment (or -1)
|
|
5269
|
+
if (
|
|
5270
|
+
string &&
|
|
5271
|
+
string.indexOf('<!--') > string.indexOf('-->')
|
|
5272
|
+
) {
|
|
5166
5273
|
return originalFn.call(thisObj, string);
|
|
5167
5274
|
}
|
|
5168
5275
|
}
|
|
5169
5276
|
|
|
5170
|
-
if (
|
|
5277
|
+
if (
|
|
5278
|
+
isSWLoad() ||
|
|
5279
|
+
(fnThis.readyState === 'loading' && wombat.wb_info.injectDocClose)
|
|
5280
|
+
) {
|
|
5171
5281
|
wombat._writeBuff += string;
|
|
5172
5282
|
return;
|
|
5173
5283
|
}
|
|
@@ -5177,7 +5287,7 @@ Wombat.prototype.initDocWriteOpenCloseOverride = function() {
|
|
|
5177
5287
|
var res = originalFn.call(thisObj, string);
|
|
5178
5288
|
wombat.initNewWindowWombat(thisObj.defaultView);
|
|
5179
5289
|
return res;
|
|
5180
|
-
}
|
|
5290
|
+
}
|
|
5181
5291
|
|
|
5182
5292
|
// Write
|
|
5183
5293
|
var orig_doc_write = $wbDocument.write;
|
|
@@ -5227,10 +5337,16 @@ Wombat.prototype.initDocWriteOpenCloseOverride = function() {
|
|
|
5227
5337
|
if (wombat._writeBuff) {
|
|
5228
5338
|
// if loading, apply as may be sync waiting for changes
|
|
5229
5339
|
if (this.readyState === 'loading') {
|
|
5230
|
-
orig_doc_write.call(
|
|
5340
|
+
orig_doc_write.call(
|
|
5341
|
+
$wbDocument,
|
|
5342
|
+
wombat.rewriteHtml(wombat._writeBuff, true)
|
|
5343
|
+
);
|
|
5231
5344
|
}
|
|
5232
5345
|
if (isSWLoad()) {
|
|
5233
|
-
wombat.blobUrlForIframe(
|
|
5346
|
+
wombat.blobUrlForIframe(
|
|
5347
|
+
wombat.$wbwindow.frameElement,
|
|
5348
|
+
wombat._writeBuff
|
|
5349
|
+
);
|
|
5234
5350
|
|
|
5235
5351
|
const doc = this;
|
|
5236
5352
|
|
|
@@ -5238,7 +5354,10 @@ Wombat.prototype.initDocWriteOpenCloseOverride = function() {
|
|
|
5238
5354
|
// catch any sync changes to doc being replaced, and create updated blob
|
|
5239
5355
|
if (doc.documentElement) {
|
|
5240
5356
|
const m = new wombat.$wbwindow.MutationObserver((mut, obs) => {
|
|
5241
|
-
wombat.blobUrlForIframe(
|
|
5357
|
+
wombat.blobUrlForIframe(
|
|
5358
|
+
wombat.$wbwindow.frameElement,
|
|
5359
|
+
doc.documentElement.outerHTML
|
|
5360
|
+
);
|
|
5242
5361
|
});
|
|
5243
5362
|
m.observe(doc.documentElement, { childList: true, subtree: true });
|
|
5244
5363
|
}
|
|
@@ -5331,10 +5450,13 @@ Wombat.prototype.initNewWindowWombat = function(win, src) {
|
|
|
5331
5450
|
fullWombat = true;
|
|
5332
5451
|
}
|
|
5333
5452
|
|
|
5334
|
-
|
|
5335
5453
|
if (!fullWombat && this.wb_info.isSW) {
|
|
5336
5454
|
var origURL = this.extractOriginalURL(src);
|
|
5337
|
-
if (
|
|
5455
|
+
if (
|
|
5456
|
+
origURL === 'about:blank' ||
|
|
5457
|
+
origURL.startsWith('srcdoc:') ||
|
|
5458
|
+
origURL.startsWith('blob:')
|
|
5459
|
+
) {
|
|
5338
5460
|
fullWombat = true;
|
|
5339
5461
|
}
|
|
5340
5462
|
}
|
|
@@ -5459,8 +5581,10 @@ Wombat.prototype.initWorkerOverrides = function() {
|
|
|
5459
5581
|
scriptURL,
|
|
5460
5582
|
options
|
|
5461
5583
|
) {
|
|
5462
|
-
var newScriptURL = new wombat.URL(
|
|
5463
|
-
|
|
5584
|
+
var newScriptURL = new wombat.URL(
|
|
5585
|
+
scriptURL,
|
|
5586
|
+
wombat.$wbwindow.document.baseURI
|
|
5587
|
+
).href;
|
|
5464
5588
|
var mod = wombat.getPageUnderModifier();
|
|
5465
5589
|
if (options && options.scope) {
|
|
5466
5590
|
options.scope = wombat.rewriteUrl(options.scope, false, mod);
|
|
@@ -5626,17 +5750,18 @@ Wombat.prototype.initCheckThisFunc = function(win) {
|
|
|
5626
5750
|
enumerable: false,
|
|
5627
5751
|
value: function(thisObj) {
|
|
5628
5752
|
try {
|
|
5629
|
-
return
|
|
5753
|
+
return thisObj && thisObj._WB_wombat_obj_proxy
|
|
5754
|
+
? thisObj._WB_wombat_obj_proxy
|
|
5755
|
+
: thisObj;
|
|
5630
5756
|
} catch (e) {
|
|
5631
5757
|
return thisObj;
|
|
5632
5758
|
}
|
|
5633
|
-
}
|
|
5759
|
+
}
|
|
5634
5760
|
});
|
|
5635
5761
|
}
|
|
5636
|
-
} catch(e) {}
|
|
5762
|
+
} catch (e) {}
|
|
5637
5763
|
};
|
|
5638
5764
|
|
|
5639
|
-
|
|
5640
5765
|
Wombat.prototype.initImportWrapperFunc = function(win) {
|
|
5641
5766
|
var wombat = this;
|
|
5642
5767
|
|
|
@@ -5673,7 +5798,9 @@ Wombat.prototype.initImportWrapperFunc = function(win) {
|
|
|
5673
5798
|
} else if (base && url === undefined) {
|
|
5674
5799
|
url = base;
|
|
5675
5800
|
}
|
|
5676
|
-
return import(
|
|
5801
|
+
return import(
|
|
5802
|
+
/*webpackIgnore: true*/ wombat.rewriteUrl(url, false, 'esm_')
|
|
5803
|
+
);
|
|
5677
5804
|
};
|
|
5678
5805
|
};
|
|
5679
5806
|
|
|
@@ -5815,7 +5942,7 @@ Wombat.prototype.initPostMessageOverride = function($wbwindow) {
|
|
|
5815
5942
|
|
|
5816
5943
|
var targetOrigin;
|
|
5817
5944
|
|
|
5818
|
-
if (typeof
|
|
5945
|
+
if (typeof targetOrigin_or_options === 'object') {
|
|
5819
5946
|
targetOrigin = targetOrigin_or_options.targetOrigin;
|
|
5820
5947
|
transfer = targetOrigin_or_options.transfer;
|
|
5821
5948
|
} else {
|
|
@@ -6130,21 +6257,23 @@ Wombat.prototype.initRegisterUnRegPHOverride = function() {
|
|
|
6130
6257
|
}
|
|
6131
6258
|
};
|
|
6132
6259
|
|
|
6133
|
-
|
|
6134
6260
|
Wombat.prototype.initMiscNavigatorOverrides = function() {
|
|
6135
6261
|
if (this.$wbwindow.navigator.sendBeacon) {
|
|
6136
|
-
this.$wbwindow.navigator.sendBeacon = function() {
|
|
6262
|
+
this.$wbwindow.navigator.sendBeacon = function() {
|
|
6263
|
+
return true;
|
|
6264
|
+
};
|
|
6137
6265
|
}
|
|
6138
|
-
Object.defineProperty(navigator, 'onLine', {value: true});
|
|
6266
|
+
Object.defineProperty(navigator, 'onLine', { value: true });
|
|
6139
6267
|
if (this.$wbwindow.navigator.mediaDevices) {
|
|
6140
6268
|
this.$wbwindow.navigator.mediaDevices.setCaptureHandleConfig = function() {};
|
|
6141
6269
|
}
|
|
6142
6270
|
if (this.$wbwindow.navigator.getInstalledRelatedApps) {
|
|
6143
|
-
this.$wbwindow.navigator.getInstalledRelatedApps = function() {
|
|
6271
|
+
this.$wbwindow.navigator.getInstalledRelatedApps = function() {
|
|
6272
|
+
return Promise.resolve([]);
|
|
6273
|
+
};
|
|
6144
6274
|
}
|
|
6145
6275
|
};
|
|
6146
6276
|
|
|
6147
|
-
|
|
6148
6277
|
/**
|
|
6149
6278
|
* Applies an override to the constructor of the PresentationRequest interface object
|
|
6150
6279
|
* in order to rewrite its URL(s) arguments
|
|
@@ -6266,7 +6395,6 @@ Wombat.prototype.initStorageOverride = function() {
|
|
|
6266
6395
|
ThrowExceptions.yes = true;
|
|
6267
6396
|
};
|
|
6268
6397
|
|
|
6269
|
-
|
|
6270
6398
|
Wombat.prototype.initIndexedDBOverride = function() {
|
|
6271
6399
|
if (!this.$wbwindow.IDBFactory) {
|
|
6272
6400
|
return;
|
|
@@ -6289,16 +6417,24 @@ Wombat.prototype.initIndexedDBOverride = function() {
|
|
|
6289
6417
|
var orig_databases = proto.databases;
|
|
6290
6418
|
proto.databases = function() {
|
|
6291
6419
|
var func = this;
|
|
6292
|
-
return new Promise(function
|
|
6293
|
-
orig_databases
|
|
6294
|
-
|
|
6295
|
-
|
|
6296
|
-
|
|
6297
|
-
|
|
6420
|
+
return new Promise(function(resolve, reject) {
|
|
6421
|
+
orig_databases
|
|
6422
|
+
.call(func)
|
|
6423
|
+
.then(function(dbList) {
|
|
6424
|
+
var keys = [];
|
|
6425
|
+
for (var i = 0; i < dbList.length; i++) {
|
|
6426
|
+
if (dbList[i].name.indexOf(prefix) === 0) {
|
|
6427
|
+
keys.push({
|
|
6428
|
+
name: dbList[i].name.substring(prefix.length),
|
|
6429
|
+
version: dbList[i].version
|
|
6430
|
+
});
|
|
6431
|
+
}
|
|
6298
6432
|
}
|
|
6299
|
-
|
|
6300
|
-
|
|
6301
|
-
|
|
6433
|
+
resolve(keys);
|
|
6434
|
+
})
|
|
6435
|
+
.catch(function(err) {
|
|
6436
|
+
reject(err);
|
|
6437
|
+
});
|
|
6302
6438
|
});
|
|
6303
6439
|
};
|
|
6304
6440
|
};
|
|
@@ -6335,7 +6471,6 @@ Wombat.prototype.initCachesOverride = function() {
|
|
|
6335
6471
|
};
|
|
6336
6472
|
};
|
|
6337
6473
|
|
|
6338
|
-
|
|
6339
6474
|
Wombat.prototype.initCacheStorageOverride = function() {
|
|
6340
6475
|
if (!this.$wbwindow.CacheStorage) {
|
|
6341
6476
|
return;
|
|
@@ -6368,16 +6503,21 @@ Wombat.prototype.initCacheStorageOverride = function() {
|
|
|
6368
6503
|
var orig_keys = proto.keys;
|
|
6369
6504
|
proto.keys = function() {
|
|
6370
6505
|
var func = this;
|
|
6371
|
-
return new Promise(function
|
|
6372
|
-
orig_keys
|
|
6373
|
-
|
|
6374
|
-
|
|
6375
|
-
|
|
6376
|
-
|
|
6506
|
+
return new Promise(function(resolve, reject) {
|
|
6507
|
+
orig_keys
|
|
6508
|
+
.call(func)
|
|
6509
|
+
.then(function(keyList) {
|
|
6510
|
+
var keys = [];
|
|
6511
|
+
for (var i = 0; i < keyList.length; i++) {
|
|
6512
|
+
if (keyList[i].indexOf(prefix) === 0) {
|
|
6513
|
+
keys.push(keyList[i].substring(prefix.length));
|
|
6514
|
+
}
|
|
6377
6515
|
}
|
|
6378
|
-
|
|
6379
|
-
|
|
6380
|
-
|
|
6516
|
+
resolve(keys);
|
|
6517
|
+
})
|
|
6518
|
+
.catch(function(err) {
|
|
6519
|
+
reject(err);
|
|
6520
|
+
});
|
|
6381
6521
|
});
|
|
6382
6522
|
};
|
|
6383
6523
|
|
|
@@ -6390,12 +6530,18 @@ Wombat.prototype.initCacheStorageOverride = function() {
|
|
|
6390
6530
|
|
|
6391
6531
|
return cacheNames.reduce(function(chain, cacheName) {
|
|
6392
6532
|
return chain.then(function() {
|
|
6393
|
-
return
|
|
6394
|
-
|
|
6395
|
-
|
|
6396
|
-
|
|
6397
|
-
|
|
6398
|
-
|
|
6533
|
+
return (
|
|
6534
|
+
match ||
|
|
6535
|
+
caches
|
|
6536
|
+
.open(cacheName)
|
|
6537
|
+
.then(function(cache) {
|
|
6538
|
+
return cache.match(request, opts);
|
|
6539
|
+
})
|
|
6540
|
+
.then(function(response) {
|
|
6541
|
+
match = response;
|
|
6542
|
+
return match;
|
|
6543
|
+
})
|
|
6544
|
+
);
|
|
6399
6545
|
});
|
|
6400
6546
|
}, Promise.resolve());
|
|
6401
6547
|
});
|
|
@@ -6433,7 +6579,6 @@ Wombat.prototype.initWindowObjProxy = function($wbwindow) {
|
|
|
6433
6579
|
|
|
6434
6580
|
// default to replay-top object proxy if all else fails
|
|
6435
6581
|
return wombat.$wbwindow.WB_wombat_top._WB_wombat_obj_proxy;
|
|
6436
|
-
|
|
6437
6582
|
}
|
|
6438
6583
|
return wombat.defaultProxyGet($wbwindow, prop, ownProps, funCache);
|
|
6439
6584
|
},
|
|
@@ -6501,7 +6646,11 @@ Wombat.prototype.initWindowObjProxy = function($wbwindow) {
|
|
|
6501
6646
|
},
|
|
6502
6647
|
defineProperty: function(target, prop, desc) {
|
|
6503
6648
|
var ndesc = desc || {};
|
|
6504
|
-
if (
|
|
6649
|
+
if (
|
|
6650
|
+
!ndesc.hasOwnProperty('value') &&
|
|
6651
|
+
!ndesc.hasOwnProperty('get') &&
|
|
6652
|
+
!ndesc.hasOwnProperty('set')
|
|
6653
|
+
) {
|
|
6505
6654
|
ndesc.value = $wbwindow[prop];
|
|
6506
6655
|
}
|
|
6507
6656
|
Reflect.defineProperty($wbwindow, prop, ndesc);
|
|
@@ -6638,7 +6787,7 @@ Wombat.prototype.initTopFrameNotify = function(wbinfo) {
|
|
|
6638
6787
|
|
|
6639
6788
|
icons.push({
|
|
6640
6789
|
rel: 'icon',
|
|
6641
|
-
href: wombat.rewriteUrl('/favicon.ico')
|
|
6790
|
+
href: wombat.rewriteUrl('/favicon.ico')
|
|
6642
6791
|
});
|
|
6643
6792
|
|
|
6644
6793
|
var message = {
|
|
@@ -6799,7 +6948,7 @@ Wombat.prototype.initEvalOverride = function() {
|
|
|
6799
6948
|
var rewriteEvalArg = this.rewriteEvalArg;
|
|
6800
6949
|
var setNoop = function() {};
|
|
6801
6950
|
|
|
6802
|
-
this.wrappedEval = function
|
|
6951
|
+
this.wrappedEval = function(evalFunc) {
|
|
6803
6952
|
return function(arg) {
|
|
6804
6953
|
return rewriteEvalArg(evalFunc, arg);
|
|
6805
6954
|
};
|
|
@@ -6840,7 +6989,7 @@ Wombat.prototype.initEvalOverride = function() {
|
|
|
6840
6989
|
return {
|
|
6841
6990
|
eval: function(thisObj, args, evalparam) {
|
|
6842
6991
|
// ensure this === window
|
|
6843
|
-
var isGlobal =
|
|
6992
|
+
var isGlobal = thisObj === wombat.proxyToObj(wombat.$wbwindow);
|
|
6844
6993
|
// wrap in try/catch in the off chance case we're in strict mode, and then treat as non-global
|
|
6845
6994
|
try {
|
|
6846
6995
|
isGlobal = isGlobal && !args.callee.caller;
|
|
@@ -6904,14 +7053,12 @@ Wombat.prototype.wombatInit = function() {
|
|
|
6904
7053
|
// proxy check this func
|
|
6905
7054
|
this.initCheckThisFunc(this.$wbwindow);
|
|
6906
7055
|
|
|
6907
|
-
|
|
6908
7056
|
// add __wb_import__ for modules
|
|
6909
7057
|
this.initImportWrapperFunc(this.$wbwindow);
|
|
6910
7058
|
|
|
6911
7059
|
// override getOwnPropertyNames
|
|
6912
7060
|
this.overrideGetOwnPropertyNames(this.$wbwindow);
|
|
6913
7061
|
|
|
6914
|
-
|
|
6915
7062
|
this.initUIEventsOverrides();
|
|
6916
7063
|
|
|
6917
7064
|
// write
|
|
@@ -6941,7 +7088,11 @@ Wombat.prototype.wombatInit = function() {
|
|
|
6941
7088
|
// can get into replay
|
|
6942
7089
|
this.overrideHtmlAssign(this.$wbwindow.Element, 'innerHTML', true);
|
|
6943
7090
|
this.overrideHtmlAssign(this.$wbwindow.Element, 'outerHTML', true);
|
|
6944
|
-
this.overrideHtmlAssignSrcDoc(
|
|
7091
|
+
this.overrideHtmlAssignSrcDoc(
|
|
7092
|
+
this.$wbwindow.HTMLIFrameElement,
|
|
7093
|
+
'srcdoc',
|
|
7094
|
+
true
|
|
7095
|
+
);
|
|
6945
7096
|
this.overrideHtmlAssign(this.$wbwindow.HTMLStyleElement, 'textContent');
|
|
6946
7097
|
this.overrideShadowDom();
|
|
6947
7098
|
|
|
@@ -6998,7 +7149,10 @@ Wombat.prototype.wombatInit = function() {
|
|
|
6998
7149
|
'dispatchEvent'
|
|
6999
7150
|
);
|
|
7000
7151
|
|
|
7001
|
-
this.overrideDeProxyPropAssign(
|
|
7152
|
+
this.overrideDeProxyPropAssign(
|
|
7153
|
+
this.$wbwindow.TreeWalker.prototype,
|
|
7154
|
+
'currentNode'
|
|
7155
|
+
);
|
|
7002
7156
|
|
|
7003
7157
|
this.initTimeoutIntervalOverrides();
|
|
7004
7158
|
|