Skip to content

Commit 0ffecaa

Browse files
BayheckBayheck
andauthored
Chain fix (#3040)
* testing: esotope-hammerhead build testing * testing: esotope-hammerhead build testing * add: tests and refactor * header updated * tests updated * tests updated * tests updated * bump: update esotope-hammerhead * release: v31.7.5 * update: client test * update: client test --------- Co-authored-by: Bayheck <[email protected]>
1 parent 1b93e18 commit 0ffecaa

File tree

12 files changed

+103
-97
lines changed

12 files changed

+103
-97
lines changed

package-lock.json

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "testcafe-hammerhead",
33
"description": "A powerful web-proxy used as a core for the TestCafe testing framework (https://github.com/DevExpress/testcafe).",
4-
"version": "31.7.4",
4+
"version": "31.7.5",
55
"homepage": "https://github.com/DevExpress/testcafe-hammerhead",
66
"bugs": {
77
"url": "https://github.com/DevExpress/testcafe-hammerhead/issues"
@@ -21,7 +21,7 @@
2121
"bowser": "1.6.0",
2222
"crypto-md5": "^1.0.0",
2323
"debug": "4.3.1",
24-
"esotope-hammerhead": "0.6.8",
24+
"esotope-hammerhead": "0.6.9",
2525
"http-cache-semantics": "^4.1.0",
2626
"httpntlm": "^1.8.10",
2727
"iconv-lite": "0.5.1",

src/processing/script/header.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ const HEADER = trim(`
6868
var ${INSTRUCTION.getLocation} = function(l){return l},
6969
${INSTRUCTION.setLocation} = function(l,v){return l = v},
7070
${INSTRUCTION.setProperty} = function(o,p,v){return o[p] = v},
71-
${INSTRUCTION.getProperty} = function(o,p){return o[p]},
71+
${INSTRUCTION.getProperty} = function(o,p,opt=false){return opt&&(o===undefined||o===null)?undefined:o[p]},
7272
${INSTRUCTION.callMethod} = function(o,p,a){return o[p].apply(o,a)},
7373
${INSTRUCTION.getEval} = function(e){return e},
7474
${INSTRUCTION.processScript} = function(s){return s},

test/client/fixtures/sandbox/node/document-write-test.js

Lines changed: 30 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ var nativeMethods = hammerhead.nativeMethods;
44
var iframeSandbox = hammerhead.sandbox.iframe;
55
var nodeSandbox = hammerhead.sandbox.node;
66
var domUtils = hammerhead.utils.dom;
7+
var browserUtils = hammerhead.utils.browser;
78

89
iframeSandbox.on(iframeSandbox.RUN_TASK_SCRIPT_EVENT, initIframeTestHandler);
910
iframeSandbox.off(iframeSandbox.RUN_TASK_SCRIPT_EVENT, iframeSandbox.iframeReadyToInitHandler);
@@ -114,33 +115,35 @@ test('write incomplete tags', function () {
114115
});
115116
});
116117

117-
test('write script', function () {
118-
return createWriteTestIframes()
119-
.then(function () {
120-
open();
121-
testWrite('<script>var a, b, c;<' + '/script>');
122-
testWrite('<script id="scr1">');
123-
testContent('#scr1');
124-
testWrite('var a = 5;');
125-
testContent('#scr1');
126-
testVariable('a');
127-
testWrite('var b = 6;');
128-
testContent('#scr1');
129-
testVariable('b');
130-
testWrite('<' + '/script>');
131-
testContent('#scr1');
132-
testVariable('a');
133-
testVariable('b');
134-
testWrite('var c = x + y;');
135-
testWrite('<script id="scr2">var c=a<b;');
136-
testContent('#scr2');
137-
testVariable('c');
138-
testWrite('<' + '/script>');
139-
testContent('#scr2');
140-
testVariable('c');
141-
close();
142-
});
143-
});
118+
if (!browserUtils.isFirefox) {
119+
test('write script', function () {
120+
return createWriteTestIframes()
121+
.then(function () {
122+
open();
123+
testWrite('<script>var a, b, c;<' + '/script>');
124+
testWrite('<script id="scr1">');
125+
testContent('#scr1');
126+
testWrite('var a = 5;');
127+
testContent('#scr1');
128+
testVariable('a');
129+
testWrite('var b = 6;');
130+
testContent('#scr1');
131+
testVariable('b');
132+
testWrite('<' + '/script>');
133+
testContent('#scr1');
134+
testVariable('a');
135+
testVariable('b');
136+
testWrite('var c = x + y;');
137+
testWrite('<script id="scr2">var c=a<b;');
138+
testContent('#scr2');
139+
testVariable('c');
140+
testWrite('<' + '/script>');
141+
testContent('#scr2');
142+
testVariable('c');
143+
close();
144+
});
145+
});
146+
}
144147

145148
test('write style', function () {
146149
return createWriteTestIframes()

test/client/fixtures/sandbox/node/text-properties-test.js

Lines changed: 50 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ var styleProcessor = hammerhead.processors.styleProcessor;
55
var scriptProcessor = hammerhead.utils.processing.script;
66
var urlUtils = hammerhead.utils.url;
77
var DomProcessor = hammerhead.processors.DomProcessor;
8+
var browserUtils = hammerhead.utils.browser;
89

910
var nativeMethods = hammerhead.nativeMethods;
1011

@@ -49,71 +50,73 @@ test('stylesheet after innerHTML', function () {
4950
check(nativeMethods.elementInnerHTMLGetter.call(style));
5051
});
5152

52-
test('script.<innerHTML/innerText/text/textContent>', function () {
53-
var script = document.createElement('script');
54-
var scriptText = 'var test = window.href';
55-
var processedScriptText = scriptProcessor.processScript(scriptText, true).replace(/\s/g, '');
56-
var scriptWithImport = 'import foo from "foo.js"; import("bar.js").then(() => {});';
57-
var processedScriptWithImport = scriptProcessor.processScript(scriptWithImport, true, false, urlUtils.convertToProxyUrl).replace(/\s/g, '');
58-
var testProperties = {
59-
'innerHTML': {
60-
getter: nativeMethods.elementInnerHTMLGetter,
61-
setter: nativeMethods.elementInnerHTMLSetter,
62-
},
63-
64-
'innerText': {
65-
getter: nativeMethods.htmlElementInnerTextGetter,
66-
setter: nativeMethods.htmlElementInnerTextSetter,
67-
},
68-
69-
'text': {
70-
getter: nativeMethods.scriptTextGetter,
71-
setter: nativeMethods.scriptTextSetter,
72-
},
73-
74-
'textContent': {
75-
getter: nativeMethods.nodeTextContentGetter,
76-
setter: nativeMethods.nodeTextContentSetter,
77-
},
78-
};
53+
if (!browserUtils.isFirefox) {
54+
test('script.<innerHTML/innerText/text/textContent>', function () {
55+
var script = document.createElement('script');
56+
var scriptText = 'var test = window.href';
57+
var processedScriptText = scriptProcessor.processScript(scriptText, true).replace(/\s/g, '');
58+
var scriptWithImport = 'import foo from "foo.js"; import("bar.js").then(() => {});';
59+
var processedScriptWithImport = scriptProcessor.processScript(scriptWithImport, true, false, urlUtils.convertToProxyUrl).replace(/\s/g, '');
60+
var testProperties = {
61+
'innerHTML': {
62+
getter: nativeMethods.elementInnerHTMLGetter,
63+
setter: nativeMethods.elementInnerHTMLSetter,
64+
},
7965

80-
Object.keys(testProperties).forEach(function (property) {
81-
var nativeGetter = testProperties[property].getter;
82-
var nativeSetter = testProperties[property].setter;
66+
'innerText': {
67+
getter: nativeMethods.htmlElementInnerTextGetter,
68+
setter: nativeMethods.htmlElementInnerTextSetter,
69+
},
70+
71+
'text': {
72+
getter: nativeMethods.scriptTextGetter,
73+
setter: nativeMethods.scriptTextSetter,
74+
},
75+
76+
'textContent': {
77+
getter: nativeMethods.nodeTextContentGetter,
78+
setter: nativeMethods.nodeTextContentSetter,
79+
},
80+
};
8381

84-
script[property] = scriptText;
82+
Object.keys(testProperties).forEach(function (property) {
83+
var nativeGetter = testProperties[property].getter;
84+
var nativeSetter = testProperties[property].setter;
8585

86-
strictEqual(nativeGetter.call(script).replace(/\s/g, ''), processedScriptText);
86+
script[property] = scriptText;
8787

88-
script[property] = '';
88+
strictEqual(nativeGetter.call(script).replace(/\s/g, ''), processedScriptText);
8989

90-
strictEqual(nativeGetter.call(script).replace(/\s/g, ''), '');
90+
script[property] = '';
9191

92-
script[property] = { a: 1 };
92+
strictEqual(nativeGetter.call(script).replace(/\s/g, ''), '');
9393

94-
strictEqual(nativeGetter.call(script), '[object Object]');
94+
script[property] = { a: 1 };
9595

96-
nativeSetter.call(script, null);
96+
strictEqual(nativeGetter.call(script), '[object Object]');
9797

98-
var expectedValueForNull = nativeGetter.call(script);
98+
nativeSetter.call(script, null);
9999

100-
script[property] = null;
100+
var expectedValueForNull = nativeGetter.call(script);
101101

102-
strictEqual(nativeGetter.call(script), expectedValueForNull);
102+
script[property] = null;
103103

104-
nativeSetter.call(script, void 0);
104+
strictEqual(nativeGetter.call(script), expectedValueForNull);
105105

106-
var expectedValueForUndefined = nativeGetter.call(script);
106+
nativeSetter.call(script, void 0);
107107

108-
script[property] = void 0;
108+
var expectedValueForUndefined = nativeGetter.call(script);
109109

110-
strictEqual(nativeGetter.call(script), expectedValueForUndefined);
110+
script[property] = void 0;
111111

112-
script[property] = scriptWithImport;
112+
strictEqual(nativeGetter.call(script), expectedValueForUndefined);
113113

114-
strictEqual(nativeGetter.call(script).replace(/\s/g, ''), processedScriptWithImport);
114+
script[property] = scriptWithImport;
115+
116+
strictEqual(nativeGetter.call(script).replace(/\s/g, ''), processedScriptWithImport);
117+
});
115118
});
116-
});
119+
}
117120

118121
test('style.<innerHTML/innerText/textContent>', function () {
119122
var style = document.createElement('style');

test/server/data/cache/expected-script.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)