testcafe 3.7.4 → 3.7.5
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/lib/assertions/executor.js +2 -2
- package/lib/browser/provider/utils/client-functions.js +1 -3
- package/lib/cli/argument-parser/index.js +3 -3
- package/lib/client/automation/index.js +5 -4
- package/lib/client/automation/playback/press/utils.js +3 -2
- package/lib/client/browser/service-worker.js +1 -1
- package/lib/client/core/index.js +6 -10
- package/lib/client/core/utils/dom.js +2 -2
- package/lib/client/driver/index.js +429 -425
- package/lib/client/driver/index.min.js +1 -1
- package/lib/client/ui/favicon.ico +0 -0
- package/lib/client/ui/index.js +426 -426
- package/lib/client/ui/index.min.js +1 -1
- package/lib/client/ui/sprite.png +0 -0
- package/lib/client-functions/replicator.js +2 -2
- package/lib/client-functions/selectors/selector-attribute-filter.js +1 -3
- package/lib/client-functions/selectors/selector-text-filter.js +1 -3
- package/lib/configuration/types.js +1 -2
- package/lib/custom-client-scripts/client-script-init.js +1 -1
- package/lib/custom-client-scripts/problematic-scripts.js +1 -1
- package/lib/custom-client-scripts/utils.js +4 -4
- package/lib/live/controller.js +5 -5
- package/lib/reporter/plugin-host.js +3 -1
- package/lib/test-run/commands/validations/argument.js +3 -2
- package/lib/test-run/index.js +2 -2
- package/lib/utils/replicator/index.js +442 -0
- package/package.json +20 -23
package/lib/client/ui/index.js
CHANGED
|
@@ -1487,7 +1487,6 @@ window['%hammerhead%'].utils.removeInjectedScript();
|
|
|
1487
1487
|
return element;
|
|
1488
1488
|
}
|
|
1489
1489
|
|
|
1490
|
-
/* eslint-disable no-restricted-properties */
|
|
1491
1490
|
var styleUtils$1 = testCafeCore__default["default"].styleUtils;
|
|
1492
1491
|
function setStyles(element, styles) {
|
|
1493
1492
|
for (var key in styles)
|
|
@@ -1555,7 +1554,6 @@ window['%hammerhead%'].utils.removeInjectedScript();
|
|
|
1555
1554
|
class: 'auxiliary-input',
|
|
1556
1555
|
};
|
|
1557
1556
|
|
|
1558
|
-
/* eslint-disable no-restricted-properties */
|
|
1559
1557
|
function addToUiRoot(element) {
|
|
1560
1558
|
if (!element.parentElement) {
|
|
1561
1559
|
var panelsContainer = uiRoot.panelsContainer();
|
|
@@ -2552,7 +2550,6 @@ window['%hammerhead%'].utils.removeInjectedScript();
|
|
|
2552
2550
|
}());
|
|
2553
2551
|
var highlighter = new Higthlighter();
|
|
2554
2552
|
|
|
2555
|
-
/* eslint-disable no-restricted-properties */
|
|
2556
2553
|
var nativeMethods$5 = hammerhead__default["default"].nativeMethods;
|
|
2557
2554
|
var ARROW_OFFSET_LEFT = 12;
|
|
2558
2555
|
function getViewportRect() {
|
|
@@ -2715,443 +2712,443 @@ window['%hammerhead%'].utils.removeInjectedScript();
|
|
|
2715
2712
|
return PickButton;
|
|
2716
2713
|
}());
|
|
2717
2714
|
|
|
2718
|
-
|
|
2719
|
-
|
|
2720
|
-
|
|
2721
|
-
|
|
2722
|
-
var
|
|
2723
|
-
|
|
2724
|
-
|
|
2725
|
-
|
|
2726
|
-
|
|
2727
|
-
|
|
2728
|
-
|
|
2729
|
-
|
|
2730
|
-
|
|
2731
|
-
|
|
2732
|
-
|
|
2733
|
-
|
|
2734
|
-
|
|
2735
|
-
|
|
2736
|
-
|
|
2737
|
-
|
|
2738
|
-
|
|
2739
|
-
|
|
2740
|
-
|
|
2741
|
-
|
|
2742
|
-
|
|
2743
|
-
|
|
2744
|
-
|
|
2745
|
-
|
|
2746
|
-
|
|
2747
|
-
|
|
2748
|
-
|
|
2749
|
-
|
|
2750
|
-
|
|
2751
|
-
|
|
2752
|
-
|
|
2753
|
-
|
|
2754
|
-
|
|
2755
|
-
|
|
2756
|
-
|
|
2757
|
-
|
|
2758
|
-
|
|
2759
|
-
|
|
2760
|
-
|
|
2761
|
-
|
|
2762
|
-
|
|
2763
|
-
|
|
2764
|
-
|
|
2765
|
-
|
|
2766
|
-
|
|
2767
|
-
|
|
2768
|
-
|
|
2769
|
-
|
|
2770
|
-
|
|
2771
|
-
|
|
2772
|
-
|
|
2773
|
-
|
|
2774
|
-
|
|
2775
|
-
|
|
2776
|
-
|
|
2777
|
-
|
|
2778
|
-
|
|
2779
|
-
|
|
2780
|
-
|
|
2781
|
-
|
|
2782
|
-
|
|
2783
|
-
|
|
2784
|
-
|
|
2785
|
-
|
|
2786
|
-
|
|
2787
|
-
|
|
2788
|
-
|
|
2789
|
-
|
|
2790
|
-
|
|
2791
|
-
|
|
2792
|
-
|
|
2793
|
-
|
|
2794
|
-
|
|
2795
|
-
|
|
2796
|
-
|
|
2797
|
-
|
|
2798
|
-
|
|
2799
|
-
|
|
2800
|
-
|
|
2801
|
-
|
|
2802
|
-
|
|
2803
|
-
|
|
2804
|
-
|
|
2805
|
-
|
|
2806
|
-
|
|
2807
|
-
|
|
2808
|
-
|
|
2809
|
-
|
|
2810
|
-
|
|
2811
|
-
|
|
2812
|
-
|
|
2813
|
-
|
|
2814
|
-
|
|
2815
|
-
|
|
2816
|
-
|
|
2817
|
-
|
|
2818
|
-
|
|
2819
|
-
|
|
2820
|
-
|
|
2821
|
-
|
|
2822
|
-
|
|
2823
|
-
|
|
2824
|
-
|
|
2825
|
-
|
|
2826
|
-
|
|
2827
|
-
|
|
2828
|
-
|
|
2829
|
-
|
|
2830
|
-
|
|
2831
|
-
|
|
2832
|
-
|
|
2833
|
-
|
|
2834
|
-
|
|
2835
|
-
|
|
2836
|
-
|
|
2837
|
-
|
|
2838
|
-
|
|
2839
|
-
|
|
2840
|
-
|
|
2841
|
-
}
|
|
2715
|
+
/* eslint-disable no-var */
|
|
2716
|
+
// Const
|
|
2717
|
+
var TRANSFORMED_TYPE_KEY = '@t';
|
|
2718
|
+
var CIRCULAR_REF_KEY = '@r';
|
|
2719
|
+
var KEY_REQUIRE_ESCAPING_RE = /^#*@(t|r)$/;
|
|
2720
|
+
var TYPED_ARRAY_CTORS = {
|
|
2721
|
+
'Int8Array': typeof Int8Array === 'function' ? Int8Array : void 0,
|
|
2722
|
+
'Uint8Array': typeof Uint8Array === 'function' ? Uint8Array : void 0,
|
|
2723
|
+
'Uint8ClampedArray': typeof Uint8ClampedArray === 'function' ? Uint8ClampedArray : void 0,
|
|
2724
|
+
'Int16Array': typeof Int16Array === 'function' ? Int16Array : void 0,
|
|
2725
|
+
'Uint16Array': typeof Uint16Array === 'function' ? Uint16Array : void 0,
|
|
2726
|
+
'Int32Array': typeof Int32Array === 'function' ? Int32Array : void 0,
|
|
2727
|
+
'Uint32Array': typeof Uint32Array === 'function' ? Uint32Array : void 0,
|
|
2728
|
+
'Float32Array': typeof Float32Array === 'function' ? Float32Array : void 0,
|
|
2729
|
+
'Float64Array': typeof Float64Array === 'function' ? Float64Array : void 0,
|
|
2730
|
+
};
|
|
2731
|
+
var SAFE_ERROR_CTORS = {
|
|
2732
|
+
'Error': Error,
|
|
2733
|
+
'EvalError': EvalError,
|
|
2734
|
+
'RangeError': RangeError,
|
|
2735
|
+
'ReferenceError': ReferenceError,
|
|
2736
|
+
'SyntaxError': SyntaxError,
|
|
2737
|
+
'TypeError': TypeError,
|
|
2738
|
+
'URIError': URIError,
|
|
2739
|
+
};
|
|
2740
|
+
var ARRAY_BUFFER_SUPPORTED = typeof ArrayBuffer === 'function';
|
|
2741
|
+
var MAP_SUPPORTED = typeof Map === 'function';
|
|
2742
|
+
var SET_SUPPORTED = typeof Set === 'function';
|
|
2743
|
+
var BUFFER_FROM_SUPPORTED = typeof Buffer === 'function';
|
|
2744
|
+
var TYPED_ARRAY_SUPPORTED = function (typeName) {
|
|
2745
|
+
return !!TYPED_ARRAY_CTORS[typeName];
|
|
2746
|
+
};
|
|
2747
|
+
// Saved proto functions
|
|
2748
|
+
var arrSlice = Array.prototype.slice;
|
|
2749
|
+
// Default serializer
|
|
2750
|
+
var JSONSerializer = {
|
|
2751
|
+
serialize: function (val) {
|
|
2752
|
+
return JSON.stringify(val);
|
|
2753
|
+
},
|
|
2754
|
+
deserialize: function (val) {
|
|
2755
|
+
return JSON.parse(val);
|
|
2756
|
+
},
|
|
2757
|
+
};
|
|
2758
|
+
// EncodingTransformer
|
|
2759
|
+
var EncodingTransformer = function (val, transforms) {
|
|
2760
|
+
this.references = val;
|
|
2761
|
+
this.transforms = transforms;
|
|
2762
|
+
this.circularCandidates = [];
|
|
2763
|
+
this.circularCandidatesDescrs = [];
|
|
2764
|
+
this.circularRefCount = 0;
|
|
2765
|
+
};
|
|
2766
|
+
EncodingTransformer._createRefMark = function (idx) {
|
|
2767
|
+
var obj = Object.create(null);
|
|
2768
|
+
obj[CIRCULAR_REF_KEY] = idx;
|
|
2769
|
+
return obj;
|
|
2770
|
+
};
|
|
2771
|
+
EncodingTransformer.prototype._createCircularCandidate = function (val, parent, key) {
|
|
2772
|
+
this.circularCandidates.push(val);
|
|
2773
|
+
this.circularCandidatesDescrs.push({ parent: parent, key: key, refIdx: -1 });
|
|
2774
|
+
};
|
|
2775
|
+
EncodingTransformer.prototype._applyTransform = function (val, parent, key, transform) {
|
|
2776
|
+
var result = Object.create(null);
|
|
2777
|
+
var serializableVal = transform.toSerializable(val);
|
|
2778
|
+
if (typeof serializableVal === 'object')
|
|
2779
|
+
this._createCircularCandidate(val, parent, key);
|
|
2780
|
+
result[TRANSFORMED_TYPE_KEY] = transform.type;
|
|
2781
|
+
result.data = this._handleValue(serializableVal, parent, key);
|
|
2782
|
+
return result;
|
|
2783
|
+
};
|
|
2784
|
+
EncodingTransformer.prototype._handleArray = function (arr) {
|
|
2785
|
+
var result = [];
|
|
2786
|
+
for (var i = 0; i < arr.length; i++)
|
|
2787
|
+
result[i] = this._handleValue(arr[i], result, i);
|
|
2788
|
+
return result;
|
|
2789
|
+
};
|
|
2790
|
+
EncodingTransformer.prototype._handlePlainObject = function (obj) {
|
|
2791
|
+
var replicator = this;
|
|
2792
|
+
var result = Object.create(null);
|
|
2793
|
+
var ownPropertyNames = Object.getOwnPropertyNames(obj);
|
|
2794
|
+
ownPropertyNames.forEach(function (key) {
|
|
2795
|
+
var resultKey = KEY_REQUIRE_ESCAPING_RE.test(key) ? '#' + key : key;
|
|
2796
|
+
result[resultKey] = replicator._handleValue(obj[key], result, resultKey);
|
|
2797
|
+
});
|
|
2798
|
+
return result;
|
|
2799
|
+
};
|
|
2800
|
+
EncodingTransformer.prototype._handleObject = function (obj, parent, key) {
|
|
2801
|
+
this._createCircularCandidate(obj, parent, key);
|
|
2802
|
+
return Array.isArray(obj) ? this._handleArray(obj) : this._handlePlainObject(obj);
|
|
2803
|
+
};
|
|
2804
|
+
EncodingTransformer.prototype._ensureCircularReference = function (obj) {
|
|
2805
|
+
var circularCandidateIdx = this.circularCandidates.indexOf(obj);
|
|
2806
|
+
if (circularCandidateIdx > -1) {
|
|
2807
|
+
var descr = this.circularCandidatesDescrs[circularCandidateIdx];
|
|
2808
|
+
if (descr.refIdx === -1)
|
|
2809
|
+
descr.refIdx = descr.parent ? ++this.circularRefCount : 0;
|
|
2810
|
+
return EncodingTransformer._createRefMark(descr.refIdx);
|
|
2811
|
+
}
|
|
2812
|
+
return null;
|
|
2813
|
+
};
|
|
2814
|
+
EncodingTransformer.prototype._handleValue = function (val, parent, key) {
|
|
2815
|
+
var type = typeof val;
|
|
2816
|
+
var isObject = type === 'object' && val !== null;
|
|
2817
|
+
if (isObject) {
|
|
2818
|
+
var refMark = this._ensureCircularReference(val);
|
|
2819
|
+
if (refMark)
|
|
2820
|
+
return refMark;
|
|
2821
|
+
}
|
|
2822
|
+
for (var i = 0; i < this.transforms.length; i++) {
|
|
2823
|
+
var transform = this.transforms[i];
|
|
2824
|
+
if (transform.shouldTransform(type, val))
|
|
2825
|
+
return this._applyTransform(val, parent, key, transform);
|
|
2826
|
+
}
|
|
2827
|
+
if (isObject)
|
|
2828
|
+
return this._handleObject(val, parent, key);
|
|
2829
|
+
return val;
|
|
2830
|
+
};
|
|
2831
|
+
EncodingTransformer.prototype.transform = function () {
|
|
2832
|
+
var references = [this._handleValue(this.references, null, null)];
|
|
2833
|
+
for (var i = 0; i < this.circularCandidatesDescrs.length; i++) {
|
|
2834
|
+
var descr = this.circularCandidatesDescrs[i];
|
|
2835
|
+
if (descr.refIdx > 0) {
|
|
2836
|
+
references[descr.refIdx] = descr.parent[descr.key];
|
|
2837
|
+
descr.parent[descr.key] = EncodingTransformer._createRefMark(descr.refIdx);
|
|
2842
2838
|
}
|
|
2843
|
-
|
|
2844
|
-
|
|
2845
|
-
|
|
2846
|
-
|
|
2847
|
-
|
|
2848
|
-
|
|
2849
|
-
|
|
2850
|
-
|
|
2851
|
-
|
|
2852
|
-
|
|
2853
|
-
|
|
2854
|
-
|
|
2855
|
-
|
|
2856
|
-
|
|
2857
|
-
|
|
2858
|
-
|
|
2859
|
-
|
|
2860
|
-
|
|
2861
|
-
|
|
2862
|
-
|
|
2863
|
-
|
|
2864
|
-
});
|
|
2865
|
-
for (var unsecapedKey in unescaped)
|
|
2866
|
-
obj[unsecapedKey] = unescaped[unsecapedKey];
|
|
2867
|
-
};
|
|
2868
|
-
DecodingTransformer.prototype._handleTransformedObject = function (obj, parent, key) {
|
|
2869
|
-
var transformType = obj[TRANSFORMED_TYPE_KEY];
|
|
2870
|
-
var transform = this.transformMap[transformType];
|
|
2871
|
-
if (!transform)
|
|
2872
|
-
throw new Error('Can\'t find transform for "' + transformType + '" type.');
|
|
2873
|
-
this.activeTransformsStack.push(obj);
|
|
2874
|
-
this._handleValue(obj.data, obj, 'data');
|
|
2875
|
-
this.activeTransformsStack.pop();
|
|
2876
|
-
parent[key] = transform.fromSerializable(obj.data);
|
|
2877
|
-
};
|
|
2878
|
-
DecodingTransformer.prototype._handleCircularSelfRefDuringTransform = function (refIdx, parent, key) {
|
|
2879
|
-
// NOTE: we've hit a hard case: object reference itself during transformation.
|
|
2880
|
-
// We can't dereference it since we don't have resulting object yet. And we'll
|
|
2881
|
-
// not be able to restore reference lately because we will need to traverse
|
|
2882
|
-
// transformed object again and reference might be unreachable or new object contain
|
|
2883
|
-
// new circular references. As a workaround we create getter, so once transformation
|
|
2884
|
-
// complete, dereferenced property will point to correct transformed object.
|
|
2885
|
-
var references = this.references;
|
|
2886
|
-
var val = void 0;
|
|
2887
|
-
Object.defineProperty(parent, key, {
|
|
2888
|
-
configurable: true,
|
|
2889
|
-
enumerable: true,
|
|
2890
|
-
get: function () {
|
|
2891
|
-
if (val === void 0)
|
|
2892
|
-
val = references[refIdx];
|
|
2893
|
-
return val;
|
|
2894
|
-
},
|
|
2895
|
-
set: function (value) {
|
|
2896
|
-
val = value;
|
|
2897
|
-
return val;
|
|
2898
|
-
}
|
|
2899
|
-
});
|
|
2900
|
-
};
|
|
2901
|
-
DecodingTransformer.prototype._handleCircularRef = function (refIdx, parent, key) {
|
|
2902
|
-
if (this.activeTransformsStack.indexOf(this.references[refIdx]) > -1)
|
|
2903
|
-
this._handleCircularSelfRefDuringTransform(refIdx, parent, key);
|
|
2904
|
-
else {
|
|
2905
|
-
if (!this.visitedRefs[refIdx]) {
|
|
2906
|
-
this.visitedRefs[refIdx] = true;
|
|
2907
|
-
this._handleValue(this.references[refIdx], this.references, refIdx);
|
|
2908
|
-
}
|
|
2909
|
-
parent[key] = this.references[refIdx];
|
|
2839
|
+
}
|
|
2840
|
+
return references;
|
|
2841
|
+
};
|
|
2842
|
+
// DecodingTransformer
|
|
2843
|
+
var DecodingTransformer = function (references, transformsMap) {
|
|
2844
|
+
this.references = references;
|
|
2845
|
+
this.transformMap = transformsMap;
|
|
2846
|
+
this.activeTransformsStack = [];
|
|
2847
|
+
this.visitedRefs = Object.create(null);
|
|
2848
|
+
};
|
|
2849
|
+
DecodingTransformer.prototype._handlePlainObject = function (obj) {
|
|
2850
|
+
var replicator = this;
|
|
2851
|
+
var unescaped = Object.create(null);
|
|
2852
|
+
var ownPropertyNames = Object.getOwnPropertyNames(obj);
|
|
2853
|
+
ownPropertyNames.forEach(function (key) {
|
|
2854
|
+
replicator._handleValue(obj[key], obj, key);
|
|
2855
|
+
if (KEY_REQUIRE_ESCAPING_RE.test(key)) {
|
|
2856
|
+
// NOTE: use intermediate object to avoid unescaped and escaped keys interference
|
|
2857
|
+
// E.g. unescaped "##@t" will be "#@t" which can overwrite escaped "#@t".
|
|
2858
|
+
unescaped[key.substring(1)] = obj[key];
|
|
2859
|
+
delete obj[key];
|
|
2910
2860
|
}
|
|
2911
|
-
};
|
|
2912
|
-
|
|
2913
|
-
|
|
2914
|
-
|
|
2915
|
-
|
|
2916
|
-
|
|
2917
|
-
|
|
2918
|
-
|
|
2919
|
-
|
|
2920
|
-
|
|
2921
|
-
|
|
2922
|
-
|
|
2861
|
+
});
|
|
2862
|
+
for (var unescapedKey in unescaped)
|
|
2863
|
+
obj[unescapedKey] = unescaped[unescapedKey];
|
|
2864
|
+
};
|
|
2865
|
+
DecodingTransformer.prototype._handleTransformedObject = function (obj, parent, key) {
|
|
2866
|
+
var transformType = obj[TRANSFORMED_TYPE_KEY];
|
|
2867
|
+
var transform = this.transformMap[transformType];
|
|
2868
|
+
if (!transform)
|
|
2869
|
+
throw new Error('Can\'t find transform for "' + transformType + '" type.');
|
|
2870
|
+
this.activeTransformsStack.push(obj);
|
|
2871
|
+
this._handleValue(obj.data, obj, 'data');
|
|
2872
|
+
this.activeTransformsStack.pop();
|
|
2873
|
+
parent[key] = transform.fromSerializable(obj.data);
|
|
2874
|
+
};
|
|
2875
|
+
DecodingTransformer.prototype._handleCircularSelfRefDuringTransform = function (refIdx, parent, key) {
|
|
2876
|
+
// NOTE: we've hit a hard case: object reference itself during transformation.
|
|
2877
|
+
// We can't dereference it since we don't have resulting object yet. And we'll
|
|
2878
|
+
// not be able to restore reference lately because we will need to traverse
|
|
2879
|
+
// transformed object again and reference might be unreachable or new object contain
|
|
2880
|
+
// new circular references. As a workaround we create getter, so once transformation
|
|
2881
|
+
// complete, dereferenced property will point to correct transformed object.
|
|
2882
|
+
var references = this.references;
|
|
2883
|
+
var val = void 0;
|
|
2884
|
+
Object.defineProperty(parent, key, {
|
|
2885
|
+
configurable: true,
|
|
2886
|
+
enumerable: true,
|
|
2887
|
+
get: function () {
|
|
2888
|
+
if (val === void 0)
|
|
2889
|
+
val = references[refIdx];
|
|
2890
|
+
return val;
|
|
2891
|
+
},
|
|
2892
|
+
set: function (value) {
|
|
2893
|
+
val = value;
|
|
2894
|
+
// eslint-disable-next-line no-setter-return
|
|
2895
|
+
return val;
|
|
2896
|
+
},
|
|
2897
|
+
});
|
|
2898
|
+
};
|
|
2899
|
+
DecodingTransformer.prototype._handleCircularRef = function (refIdx, parent, key) {
|
|
2900
|
+
if (this.activeTransformsStack.indexOf(this.references[refIdx]) > -1)
|
|
2901
|
+
this._handleCircularSelfRefDuringTransform(refIdx, parent, key);
|
|
2902
|
+
else {
|
|
2903
|
+
if (!this.visitedRefs[refIdx]) {
|
|
2904
|
+
this.visitedRefs[refIdx] = true;
|
|
2905
|
+
this._handleValue(this.references[refIdx], this.references, refIdx);
|
|
2923
2906
|
}
|
|
2924
|
-
|
|
2925
|
-
|
|
2926
|
-
|
|
2927
|
-
|
|
2928
|
-
|
|
2929
|
-
|
|
2930
|
-
|
|
2931
|
-
|
|
2932
|
-
|
|
2933
|
-
|
|
2934
|
-
|
|
2935
|
-
|
|
2936
|
-
|
|
2937
|
-
|
|
2938
|
-
|
|
2939
|
-
|
|
2940
|
-
|
|
2941
|
-
|
|
2942
|
-
|
|
2943
|
-
|
|
2944
|
-
|
|
2907
|
+
parent[key] = this.references[refIdx];
|
|
2908
|
+
}
|
|
2909
|
+
};
|
|
2910
|
+
DecodingTransformer.prototype._handleValue = function (val, parent, key) {
|
|
2911
|
+
if (typeof val !== 'object' || val === null)
|
|
2912
|
+
return;
|
|
2913
|
+
var refIdx = val[CIRCULAR_REF_KEY];
|
|
2914
|
+
if (refIdx !== void 0)
|
|
2915
|
+
this._handleCircularRef(refIdx, parent, key);
|
|
2916
|
+
else if (val[TRANSFORMED_TYPE_KEY])
|
|
2917
|
+
this._handleTransformedObject(val, parent, key);
|
|
2918
|
+
else if (Array.isArray(val)) {
|
|
2919
|
+
for (var i = 0; i < val.length; i++)
|
|
2920
|
+
this._handleValue(val[i], val, i);
|
|
2921
|
+
}
|
|
2922
|
+
else
|
|
2923
|
+
this._handlePlainObject(val);
|
|
2924
|
+
};
|
|
2925
|
+
DecodingTransformer.prototype.transform = function () {
|
|
2926
|
+
this.visitedRefs[0] = true;
|
|
2927
|
+
this._handleValue(this.references[0], this.references, 0);
|
|
2928
|
+
return this.references[0];
|
|
2929
|
+
};
|
|
2930
|
+
// Transforms
|
|
2931
|
+
var builtInTransforms = [
|
|
2932
|
+
{
|
|
2933
|
+
type: '[[NaN]]',
|
|
2934
|
+
shouldTransform: function (type, val) {
|
|
2935
|
+
return type === 'number' && isNaN(val);
|
|
2945
2936
|
},
|
|
2946
|
-
{
|
|
2947
|
-
|
|
2948
|
-
shouldTransform: function (type) {
|
|
2949
|
-
return type === 'undefined';
|
|
2950
|
-
},
|
|
2951
|
-
toSerializable: function () {
|
|
2952
|
-
return '';
|
|
2953
|
-
},
|
|
2954
|
-
fromSerializable: function () {
|
|
2955
|
-
return void 0;
|
|
2956
|
-
}
|
|
2937
|
+
toSerializable: function () {
|
|
2938
|
+
return '';
|
|
2957
2939
|
},
|
|
2958
|
-
{
|
|
2959
|
-
|
|
2960
|
-
shouldTransform: function (type, val) {
|
|
2961
|
-
return val instanceof Date;
|
|
2962
|
-
},
|
|
2963
|
-
toSerializable: function (date) {
|
|
2964
|
-
return date.getTime();
|
|
2965
|
-
},
|
|
2966
|
-
fromSerializable: function (val) {
|
|
2967
|
-
var date = new Date();
|
|
2968
|
-
date.setTime(val);
|
|
2969
|
-
return date;
|
|
2970
|
-
}
|
|
2940
|
+
fromSerializable: function () {
|
|
2941
|
+
return NaN;
|
|
2971
2942
|
},
|
|
2972
|
-
|
|
2973
|
-
|
|
2974
|
-
|
|
2975
|
-
|
|
2976
|
-
|
|
2977
|
-
toSerializable: function (re) {
|
|
2978
|
-
var result = {
|
|
2979
|
-
src: re.source,
|
|
2980
|
-
flags: ''
|
|
2981
|
-
};
|
|
2982
|
-
if (re.global)
|
|
2983
|
-
result.flags += 'g';
|
|
2984
|
-
if (re.ignoreCase)
|
|
2985
|
-
result.flags += 'i';
|
|
2986
|
-
if (re.multiline)
|
|
2987
|
-
result.flags += 'm';
|
|
2988
|
-
return result;
|
|
2989
|
-
},
|
|
2990
|
-
fromSerializable: function (val) {
|
|
2991
|
-
return new RegExp(val.src, val.flags);
|
|
2992
|
-
}
|
|
2943
|
+
},
|
|
2944
|
+
{
|
|
2945
|
+
type: '[[undefined]]',
|
|
2946
|
+
shouldTransform: function (type) {
|
|
2947
|
+
return type === 'undefined';
|
|
2993
2948
|
},
|
|
2994
|
-
{
|
|
2995
|
-
|
|
2996
|
-
|
|
2997
|
-
|
|
2998
|
-
|
|
2999
|
-
|
|
3000
|
-
|
|
3001
|
-
|
|
3002
|
-
|
|
3003
|
-
|
|
3004
|
-
|
|
3005
|
-
|
|
3006
|
-
|
|
3007
|
-
|
|
3008
|
-
|
|
3009
|
-
|
|
3010
|
-
|
|
3011
|
-
|
|
2949
|
+
toSerializable: function () {
|
|
2950
|
+
return '';
|
|
2951
|
+
},
|
|
2952
|
+
fromSerializable: function () {
|
|
2953
|
+
return void 0;
|
|
2954
|
+
},
|
|
2955
|
+
},
|
|
2956
|
+
{
|
|
2957
|
+
type: '[[Date]]',
|
|
2958
|
+
shouldTransform: function (type, val) {
|
|
2959
|
+
return val instanceof Date;
|
|
2960
|
+
},
|
|
2961
|
+
toSerializable: function (date) {
|
|
2962
|
+
return date.getTime();
|
|
2963
|
+
},
|
|
2964
|
+
fromSerializable: function (val) {
|
|
2965
|
+
var date = new Date();
|
|
2966
|
+
date.setTime(val);
|
|
2967
|
+
return date;
|
|
2968
|
+
},
|
|
2969
|
+
},
|
|
2970
|
+
{
|
|
2971
|
+
type: '[[RegExp]]',
|
|
2972
|
+
shouldTransform: function (type, val) {
|
|
2973
|
+
return val instanceof RegExp;
|
|
2974
|
+
},
|
|
2975
|
+
toSerializable: function (re) {
|
|
2976
|
+
var result = {
|
|
2977
|
+
src: re.source,
|
|
2978
|
+
flags: '',
|
|
2979
|
+
};
|
|
2980
|
+
if (re.global)
|
|
2981
|
+
result.flags += 'g';
|
|
2982
|
+
if (re.ignoreCase)
|
|
2983
|
+
result.flags += 'i';
|
|
2984
|
+
if (re.multiline)
|
|
2985
|
+
result.flags += 'm';
|
|
2986
|
+
return result;
|
|
2987
|
+
},
|
|
2988
|
+
fromSerializable: function (val) {
|
|
2989
|
+
return new RegExp(val.src, val.flags);
|
|
2990
|
+
},
|
|
2991
|
+
},
|
|
2992
|
+
{
|
|
2993
|
+
type: '[[Error]]',
|
|
2994
|
+
shouldTransform: function (type, val) {
|
|
2995
|
+
return val instanceof Error;
|
|
2996
|
+
},
|
|
2997
|
+
toSerializable: function (err) {
|
|
2998
|
+
return {
|
|
2999
|
+
name: err.name,
|
|
3000
|
+
message: err.message,
|
|
3001
|
+
stack: err.stack,
|
|
3002
|
+
};
|
|
3012
3003
|
},
|
|
3013
|
-
{
|
|
3014
|
-
|
|
3015
|
-
|
|
3016
|
-
|
|
3017
|
-
|
|
3018
|
-
|
|
3004
|
+
fromSerializable: function (val) {
|
|
3005
|
+
var Ctor = SAFE_ERROR_CTORS[val.name] || Error;
|
|
3006
|
+
var err = new Ctor(val.message);
|
|
3007
|
+
err.stack = val.stack;
|
|
3008
|
+
return err;
|
|
3009
|
+
},
|
|
3010
|
+
},
|
|
3011
|
+
{
|
|
3012
|
+
type: '[[ArrayBuffer]]',
|
|
3013
|
+
shouldTransform: function (type, val) {
|
|
3014
|
+
return ARRAY_BUFFER_SUPPORTED && val instanceof ArrayBuffer;
|
|
3015
|
+
},
|
|
3016
|
+
toSerializable: function (buffer) {
|
|
3017
|
+
var view = new Int8Array(buffer);
|
|
3018
|
+
return arrSlice.call(view);
|
|
3019
|
+
},
|
|
3020
|
+
fromSerializable: function (val) {
|
|
3021
|
+
if (ARRAY_BUFFER_SUPPORTED) {
|
|
3022
|
+
var buffer = new ArrayBuffer(val.length);
|
|
3019
3023
|
var view = new Int8Array(buffer);
|
|
3020
|
-
|
|
3021
|
-
|
|
3022
|
-
fromSerializable: function (val) {
|
|
3023
|
-
if (ARRAY_BUFFER_SUPPORTED) {
|
|
3024
|
-
var buffer = new ArrayBuffer(val.length);
|
|
3025
|
-
var view = new Int8Array(buffer);
|
|
3026
|
-
view.set(val);
|
|
3027
|
-
return buffer;
|
|
3028
|
-
}
|
|
3029
|
-
return val;
|
|
3024
|
+
view.set(val);
|
|
3025
|
+
return buffer;
|
|
3030
3026
|
}
|
|
3027
|
+
return val;
|
|
3031
3028
|
},
|
|
3032
|
-
|
|
3033
|
-
|
|
3034
|
-
|
|
3035
|
-
|
|
3036
|
-
|
|
3037
|
-
toSerializable: function (buffer) {
|
|
3038
|
-
return arrSlice.call(buffer);
|
|
3039
|
-
},
|
|
3040
|
-
fromSerializable: function (val) {
|
|
3041
|
-
if (BUFFER_FROM_SUPPORTED)
|
|
3042
|
-
return Buffer.from(val);
|
|
3043
|
-
return val;
|
|
3044
|
-
}
|
|
3029
|
+
},
|
|
3030
|
+
{
|
|
3031
|
+
type: '[[Buffer]]',
|
|
3032
|
+
shouldTransform: function (type, val) {
|
|
3033
|
+
return BUFFER_FROM_SUPPORTED && val instanceof Buffer;
|
|
3045
3034
|
},
|
|
3046
|
-
{
|
|
3047
|
-
|
|
3048
|
-
shouldTransform: function (type, val) {
|
|
3049
|
-
return Object.keys(TYPED_ARRAY_CTORS).some(function (ctorName) {
|
|
3050
|
-
return TYPED_ARRAY_SUPPORTED(ctorName) && val instanceof TYPED_ARRAY_CTORS[ctorName];
|
|
3051
|
-
});
|
|
3052
|
-
},
|
|
3053
|
-
toSerializable: function (arr) {
|
|
3054
|
-
return {
|
|
3055
|
-
ctorName: arr.constructor.name,
|
|
3056
|
-
arr: arrSlice.call(arr)
|
|
3057
|
-
};
|
|
3058
|
-
},
|
|
3059
|
-
fromSerializable: function (val) {
|
|
3060
|
-
return TYPED_ARRAY_SUPPORTED(val.ctorName) ? new TYPED_ARRAY_CTORS[val.ctorName](val.arr) : val.arr;
|
|
3061
|
-
}
|
|
3035
|
+
toSerializable: function (buffer) {
|
|
3036
|
+
return arrSlice.call(buffer);
|
|
3062
3037
|
},
|
|
3063
|
-
{
|
|
3064
|
-
|
|
3065
|
-
|
|
3066
|
-
|
|
3067
|
-
|
|
3068
|
-
|
|
3069
|
-
|
|
3070
|
-
|
|
3071
|
-
|
|
3072
|
-
|
|
3073
|
-
|
|
3074
|
-
|
|
3075
|
-
|
|
3076
|
-
|
|
3077
|
-
|
|
3078
|
-
|
|
3079
|
-
|
|
3080
|
-
|
|
3081
|
-
|
|
3082
|
-
|
|
3083
|
-
|
|
3084
|
-
|
|
3085
|
-
|
|
3086
|
-
|
|
3087
|
-
|
|
3038
|
+
fromSerializable: function (val) {
|
|
3039
|
+
if (BUFFER_FROM_SUPPORTED)
|
|
3040
|
+
return Buffer.from(val);
|
|
3041
|
+
return val;
|
|
3042
|
+
},
|
|
3043
|
+
},
|
|
3044
|
+
{
|
|
3045
|
+
type: '[[TypedArray]]',
|
|
3046
|
+
shouldTransform: function (type, val) {
|
|
3047
|
+
return Object.keys(TYPED_ARRAY_CTORS).some(function (ctorName) {
|
|
3048
|
+
return TYPED_ARRAY_SUPPORTED(ctorName) && val instanceof TYPED_ARRAY_CTORS[ctorName];
|
|
3049
|
+
});
|
|
3050
|
+
},
|
|
3051
|
+
toSerializable: function (arr) {
|
|
3052
|
+
return {
|
|
3053
|
+
ctorName: arr.constructor.name,
|
|
3054
|
+
arr: arrSlice.call(arr),
|
|
3055
|
+
};
|
|
3056
|
+
},
|
|
3057
|
+
fromSerializable: function (val) {
|
|
3058
|
+
return TYPED_ARRAY_SUPPORTED(val.ctorName) ? new TYPED_ARRAY_CTORS[val.ctorName](val.arr) : val.arr;
|
|
3059
|
+
},
|
|
3060
|
+
},
|
|
3061
|
+
{
|
|
3062
|
+
type: '[[Map]]',
|
|
3063
|
+
shouldTransform: function (type, val) {
|
|
3064
|
+
return MAP_SUPPORTED && val instanceof Map;
|
|
3065
|
+
},
|
|
3066
|
+
toSerializable: function (map) {
|
|
3067
|
+
var flattenedKVArr = [];
|
|
3068
|
+
map.forEach(function (val, key) {
|
|
3069
|
+
flattenedKVArr.push(key);
|
|
3070
|
+
flattenedKVArr.push(val);
|
|
3071
|
+
});
|
|
3072
|
+
return flattenedKVArr;
|
|
3073
|
+
},
|
|
3074
|
+
fromSerializable: function (val) {
|
|
3075
|
+
if (MAP_SUPPORTED) {
|
|
3076
|
+
// NOTE: new Map(iterable) is not supported by all browsers
|
|
3077
|
+
var map = new Map();
|
|
3078
|
+
for (var i = 0; i < val.length; i += 2)
|
|
3079
|
+
map.set(val[i], val[i + 1]);
|
|
3080
|
+
return map;
|
|
3088
3081
|
}
|
|
3082
|
+
var kvArr = [];
|
|
3083
|
+
for (var j = 0; j < val.length; j += 2)
|
|
3084
|
+
kvArr.push([val[j], val[j + 1]]);
|
|
3085
|
+
return kvArr;
|
|
3089
3086
|
},
|
|
3090
|
-
|
|
3091
|
-
|
|
3092
|
-
|
|
3093
|
-
|
|
3094
|
-
|
|
3095
|
-
|
|
3096
|
-
|
|
3097
|
-
|
|
3098
|
-
|
|
3099
|
-
|
|
3100
|
-
|
|
3101
|
-
|
|
3102
|
-
|
|
3103
|
-
|
|
3104
|
-
|
|
3105
|
-
|
|
3106
|
-
|
|
3107
|
-
|
|
3108
|
-
|
|
3109
|
-
|
|
3110
|
-
return val;
|
|
3087
|
+
},
|
|
3088
|
+
{
|
|
3089
|
+
type: '[[Set]]',
|
|
3090
|
+
shouldTransform: function (type, val) {
|
|
3091
|
+
return SET_SUPPORTED && val instanceof Set;
|
|
3092
|
+
},
|
|
3093
|
+
toSerializable: function (set) {
|
|
3094
|
+
var arr = [];
|
|
3095
|
+
set.forEach(function (val) {
|
|
3096
|
+
arr.push(val);
|
|
3097
|
+
});
|
|
3098
|
+
return arr;
|
|
3099
|
+
},
|
|
3100
|
+
fromSerializable: function (val) {
|
|
3101
|
+
if (SET_SUPPORTED) {
|
|
3102
|
+
// NOTE: new Set(iterable) is not supported by all browsers
|
|
3103
|
+
var set = new Set();
|
|
3104
|
+
for (var i = 0; i < val.length; i++)
|
|
3105
|
+
set.add(val[i]);
|
|
3106
|
+
return set;
|
|
3111
3107
|
}
|
|
3112
|
-
|
|
3113
|
-
|
|
3114
|
-
|
|
3115
|
-
|
|
3116
|
-
|
|
3117
|
-
|
|
3118
|
-
|
|
3119
|
-
|
|
3120
|
-
|
|
3121
|
-
|
|
3122
|
-
|
|
3123
|
-
|
|
3124
|
-
|
|
3125
|
-
|
|
3126
|
-
|
|
3127
|
-
|
|
3128
|
-
|
|
3129
|
-
|
|
3130
|
-
|
|
3131
|
-
|
|
3132
|
-
}
|
|
3133
|
-
|
|
3134
|
-
|
|
3135
|
-
|
|
3136
|
-
|
|
3137
|
-
|
|
3138
|
-
|
|
3139
|
-
|
|
3140
|
-
|
|
3141
|
-
|
|
3142
|
-
|
|
3143
|
-
}
|
|
3144
|
-
|
|
3145
|
-
|
|
3146
|
-
|
|
3147
|
-
|
|
3148
|
-
|
|
3149
|
-
|
|
3150
|
-
|
|
3151
|
-
|
|
3152
|
-
|
|
3153
|
-
|
|
3154
|
-
|
|
3108
|
+
return val;
|
|
3109
|
+
},
|
|
3110
|
+
},
|
|
3111
|
+
];
|
|
3112
|
+
// Replicator
|
|
3113
|
+
var Replicator = function (serializer) {
|
|
3114
|
+
this.transforms = [];
|
|
3115
|
+
this.transformsMap = Object.create(null);
|
|
3116
|
+
this.serializer = serializer || JSONSerializer;
|
|
3117
|
+
this.addTransforms(builtInTransforms);
|
|
3118
|
+
};
|
|
3119
|
+
// Manage transforms
|
|
3120
|
+
Replicator.prototype.addTransforms = function (transforms) {
|
|
3121
|
+
transforms = Array.isArray(transforms) ? transforms : [transforms];
|
|
3122
|
+
for (var i = 0; i < transforms.length; i++) {
|
|
3123
|
+
var transform = transforms[i];
|
|
3124
|
+
if (this.transformsMap[transform.type])
|
|
3125
|
+
throw new Error('Transform with type "' + transform.type + '" was already added.');
|
|
3126
|
+
this.transforms.push(transform);
|
|
3127
|
+
this.transformsMap[transform.type] = transform;
|
|
3128
|
+
}
|
|
3129
|
+
return this;
|
|
3130
|
+
};
|
|
3131
|
+
Replicator.prototype.removeTransforms = function (transforms) {
|
|
3132
|
+
transforms = Array.isArray(transforms) ? transforms : [transforms];
|
|
3133
|
+
for (var i = 0; i < transforms.length; i++) {
|
|
3134
|
+
var transform = transforms[i];
|
|
3135
|
+
var idx = this.transforms.indexOf(transform);
|
|
3136
|
+
if (idx > -1)
|
|
3137
|
+
this.transforms.splice(idx, 1);
|
|
3138
|
+
delete this.transformsMap[transform.type];
|
|
3139
|
+
}
|
|
3140
|
+
return this;
|
|
3141
|
+
};
|
|
3142
|
+
Replicator.prototype.encode = function (val) {
|
|
3143
|
+
var transformer = new EncodingTransformer(val, this.transforms);
|
|
3144
|
+
var references = transformer.transform();
|
|
3145
|
+
return this.serializer.serialize(references);
|
|
3146
|
+
};
|
|
3147
|
+
Replicator.prototype.decode = function (val) {
|
|
3148
|
+
var references = this.serializer.deserialize(val);
|
|
3149
|
+
var transformer = new DecodingTransformer(references, this.transformsMap);
|
|
3150
|
+
return transformer.transform();
|
|
3151
|
+
};
|
|
3155
3152
|
|
|
3156
3153
|
var identity = function (val) { return val; };
|
|
3157
3154
|
function createReplicator(transforms) {
|
|
@@ -3159,11 +3156,11 @@ window['%hammerhead%'].utils.removeInjectedScript();
|
|
|
3159
3156
|
// to JSON with a command or command result.
|
|
3160
3157
|
// Therefore there is no need to do additional job here,
|
|
3161
3158
|
// so we use identity functions for serialization.
|
|
3162
|
-
var replicator
|
|
3159
|
+
var replicator = new Replicator({
|
|
3163
3160
|
serialize: identity,
|
|
3164
3161
|
deserialize: identity,
|
|
3165
3162
|
});
|
|
3166
|
-
return replicator
|
|
3163
|
+
return replicator.addTransforms(transforms);
|
|
3167
3164
|
}
|
|
3168
3165
|
|
|
3169
3166
|
// -------------------------------------------------------------
|
|
@@ -3955,8 +3952,10 @@ window['%hammerhead%'].utils.removeInjectedScript();
|
|
|
3955
3952
|
throw new DomNodeClientFunctionResultError(this._instantiationCallsiteName);
|
|
3956
3953
|
return false;
|
|
3957
3954
|
};
|
|
3955
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
3958
3956
|
ClientFunctionNodeTransform.prototype.toSerializable = function () {
|
|
3959
3957
|
};
|
|
3958
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
3960
3959
|
ClientFunctionNodeTransform.prototype.fromSerializable = function () {
|
|
3961
3960
|
};
|
|
3962
3961
|
return ClientFunctionNodeTransform;
|
|
@@ -4163,6 +4162,7 @@ window['%hammerhead%'].utils.removeInjectedScript();
|
|
|
4163
4162
|
this._extend(snapshot, node);
|
|
4164
4163
|
return snapshot;
|
|
4165
4164
|
};
|
|
4165
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
4166
4166
|
SelectorNodeTransform.prototype.fromSerializable = function () {
|
|
4167
4167
|
};
|
|
4168
4168
|
return SelectorNodeTransform;
|