Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/processing/script/header.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,15 @@ const STRICT_MODE_PLACEHOLDER = '{strict-placeholder}';
const SW_SCOPE_HEADER_VALUE = '{sw-scope-header-value}';
const WORKER_SETTINGS_PLACEHOLDER = '{worker-settings}';

// NOTE: we need try/catch if a worker with ES module (fix for https://github.com/DevExpress/testcafe/issues/8251)
const IMPORT_WORKER_HAMMERHEAD = `
if (typeof importScripts !== "undefined" && /\\[native code]/g.test(importScripts.toString())) {
var ${INSTRUCTION.getWorkerSettings} = function () {return ${WORKER_SETTINGS_PLACEHOLDER}};
importScripts((location.origin || (location.protocol + "//" + location.host)) + "${SERVICE_ROUTES.workerHammerhead}");
try {
importScripts((location.origin || (location.protocol + "//" + location.host)) + "${SERVICE_ROUTES.workerHammerhead}");
} catch (e) {
(async function () { await import((location.origin || (location.protocol + "//" + location.host)) + "${SERVICE_ROUTES.workerHammerhead}"); })();
}
}
`;

Expand Down
2 changes: 1 addition & 1 deletion test/server/data/cache/expected-script.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions test/server/data/html-import-page/expected.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
}

/*hammerhead|stylesheet|end*/</style>
<script type="text/javascript">/*hammerhead|script|start*/if (typeof globalThis.window !== 'undefined' && globalThis.window){globalThis.window['hammerhead|process-dom-method'] && globalThis.window['hammerhead|process-dom-method']();if (globalThis.window.__get$ && typeof __get$ === 'undefined')var __get$Loc = globalThis.window.__get$Loc,__set$Loc = globalThis.window.__set$Loc,__set$ = globalThis.window.__set$,__get$ = globalThis.window.__get$,__call$ = globalThis.window.__call$,__get$Eval = globalThis.window.__get$Eval,__proc$Script = globalThis.window.__proc$Script,__proc$Html = globalThis.window.__proc$Html,__get$PostMessage = globalThis.window.__get$PostMessage,__get$ProxyUrl = globalThis.window.__get$ProxyUrl,__rest$Array = globalThis.window.__rest$Array,__rest$Object = globalThis.window.__rest$Object,__arrayFrom$ = globalThis.window.__arrayFrom$;} else {if (typeof __get$ === 'undefined')var __get$Loc = function(l){return l},__set$Loc = function(l,v){return l = v},__set$ = function(o,p,v){return o[p] = v},__get$ = function(o,p,opt=false){return opt&&(o===undefined||o===null)?undefined:o[p]},__call$ = function(o,p,a){return o[p].apply(o,a)},__get$Eval = function(e){return e},__proc$Script = function(s){return s},__proc$Html = function(h){return h},__get$PostMessage = function(w,p){return arguments.length===1?w.postMessage:p},__get$ProxyUrl = function(u,d){return u},__rest$Array = function(a,i){return Array.prototype.slice.call(a, i)},__rest$Object = function(o,p){var k=Object.keys(o),n={};for(var i=0;i<k.length;++i)if(p.indexOf(k[i])<0)n[k[i]]=o[k[i]];return n},__arrayFrom$ = function(r){if(!r)return r;return!Array.isArray(r)&&"function"==typeof r[Symbol.iterator]?Array.from(r):r};if (typeof importScripts !== "undefined" && /\[native code]/g.test(importScripts.toString())) {var __getWorkerSettings$ = function () {return null};importScripts((location.origin || (location.protocol + "//" + location.host)) + "/worker-hammerhead.js");}}/*hammerhead|script|processing-header-end*/
<script type="text/javascript">/*hammerhead|script|start*/if (typeof globalThis.window !== 'undefined' && globalThis.window){globalThis.window['hammerhead|process-dom-method'] && globalThis.window['hammerhead|process-dom-method']();if (globalThis.window.__get$ && typeof __get$ === 'undefined')var __get$Loc = globalThis.window.__get$Loc,__set$Loc = globalThis.window.__set$Loc,__set$ = globalThis.window.__set$,__get$ = globalThis.window.__get$,__call$ = globalThis.window.__call$,__get$Eval = globalThis.window.__get$Eval,__proc$Script = globalThis.window.__proc$Script,__proc$Html = globalThis.window.__proc$Html,__get$PostMessage = globalThis.window.__get$PostMessage,__get$ProxyUrl = globalThis.window.__get$ProxyUrl,__rest$Array = globalThis.window.__rest$Array,__rest$Object = globalThis.window.__rest$Object,__arrayFrom$ = globalThis.window.__arrayFrom$;} else {if (typeof __get$ === 'undefined')var __get$Loc = function(l){return l},__set$Loc = function(l,v){return l = v},__set$ = function(o,p,v){return o[p] = v},__get$ = function(o,p,opt=false){return opt&&(o===undefined||o===null)?undefined:o[p]},__call$ = function(o,p,a){return o[p].apply(o,a)},__get$Eval = function(e){return e},__proc$Script = function(s){return s},__proc$Html = function(h){return h},__get$PostMessage = function(w,p){return arguments.length===1?w.postMessage:p},__get$ProxyUrl = function(u,d){return u},__rest$Array = function(a,i){return Array.prototype.slice.call(a, i)},__rest$Object = function(o,p){var k=Object.keys(o),n={};for(var i=0;i<k.length;++i)if(p.indexOf(k[i])<0)n[k[i]]=o[k[i]];return n},__arrayFrom$ = function(r){if(!r)return r;return!Array.isArray(r)&&"function"==typeof r[Symbol.iterator]?Array.from(r):r};if (typeof importScripts !== "undefined" && /\[native code]/g.test(importScripts.toString())) {var __getWorkerSettings$ = function () {return null};try {importScripts((location.origin || (location.protocol + "//" + location.host)) + "/worker-hammerhead.js");} catch (e) {(async function () { await import((location.origin || (location.protocol + "//" + location.host)) + "/worker-hammerhead.js"); })();}}}/*hammerhead|script|processing-header-end*/

{
a : __get$(window,"location")
Expand All @@ -31,7 +31,7 @@
<!-- T217636: Health monitor - script incorrectly processes html-comments (flipkart.com) -->
<script type="text/javascript">
<!--<script type="text/javascript">-->
/*hammerhead|script|start*/if (typeof globalThis.window !== 'undefined' && globalThis.window){globalThis.window['hammerhead|process-dom-method'] && globalThis.window['hammerhead|process-dom-method']();if (globalThis.window.__get$ && typeof __get$ === 'undefined')var __get$Loc = globalThis.window.__get$Loc,__set$Loc = globalThis.window.__set$Loc,__set$ = globalThis.window.__set$,__get$ = globalThis.window.__get$,__call$ = globalThis.window.__call$,__get$Eval = globalThis.window.__get$Eval,__proc$Script = globalThis.window.__proc$Script,__proc$Html = globalThis.window.__proc$Html,__get$PostMessage = globalThis.window.__get$PostMessage,__get$ProxyUrl = globalThis.window.__get$ProxyUrl,__rest$Array = globalThis.window.__rest$Array,__rest$Object = globalThis.window.__rest$Object,__arrayFrom$ = globalThis.window.__arrayFrom$;} else {if (typeof __get$ === 'undefined')var __get$Loc = function(l){return l},__set$Loc = function(l,v){return l = v},__set$ = function(o,p,v){return o[p] = v},__get$ = function(o,p,opt=false){return opt&&(o===undefined||o===null)?undefined:o[p]},__call$ = function(o,p,a){return o[p].apply(o,a)},__get$Eval = function(e){return e},__proc$Script = function(s){return s},__proc$Html = function(h){return h},__get$PostMessage = function(w,p){return arguments.length===1?w.postMessage:p},__get$ProxyUrl = function(u,d){return u},__rest$Array = function(a,i){return Array.prototype.slice.call(a, i)},__rest$Object = function(o,p){var k=Object.keys(o),n={};for(var i=0;i<k.length;++i)if(p.indexOf(k[i])<0)n[k[i]]=o[k[i]];return n},__arrayFrom$ = function(r){if(!r)return r;return!Array.isArray(r)&&"function"==typeof r[Symbol.iterator]?Array.from(r):r};if (typeof importScripts !== "undefined" && /\[native code]/g.test(importScripts.toString())) {var __getWorkerSettings$ = function () {return null};importScripts((location.origin || (location.protocol + "//" + location.host)) + "/worker-hammerhead.js");}}/*hammerhead|script|processing-header-end*/
/*hammerhead|script|start*/if (typeof globalThis.window !== 'undefined' && globalThis.window){globalThis.window['hammerhead|process-dom-method'] && globalThis.window['hammerhead|process-dom-method']();if (globalThis.window.__get$ && typeof __get$ === 'undefined')var __get$Loc = globalThis.window.__get$Loc,__set$Loc = globalThis.window.__set$Loc,__set$ = globalThis.window.__set$,__get$ = globalThis.window.__get$,__call$ = globalThis.window.__call$,__get$Eval = globalThis.window.__get$Eval,__proc$Script = globalThis.window.__proc$Script,__proc$Html = globalThis.window.__proc$Html,__get$PostMessage = globalThis.window.__get$PostMessage,__get$ProxyUrl = globalThis.window.__get$ProxyUrl,__rest$Array = globalThis.window.__rest$Array,__rest$Object = globalThis.window.__rest$Object,__arrayFrom$ = globalThis.window.__arrayFrom$;} else {if (typeof __get$ === 'undefined')var __get$Loc = function(l){return l},__set$Loc = function(l,v){return l = v},__set$ = function(o,p,v){return o[p] = v},__get$ = function(o,p,opt=false){return opt&&(o===undefined||o===null)?undefined:o[p]},__call$ = function(o,p,a){return o[p].apply(o,a)},__get$Eval = function(e){return e},__proc$Script = function(s){return s},__proc$Html = function(h){return h},__get$PostMessage = function(w,p){return arguments.length===1?w.postMessage:p},__get$ProxyUrl = function(u,d){return u},__rest$Array = function(a,i){return Array.prototype.slice.call(a, i)},__rest$Object = function(o,p){var k=Object.keys(o),n={};for(var i=0;i<k.length;++i)if(p.indexOf(k[i])<0)n[k[i]]=o[k[i]];return n},__arrayFrom$ = function(r){if(!r)return r;return!Array.isArray(r)&&"function"==typeof r[Symbol.iterator]?Array.from(r):r};if (typeof importScripts !== "undefined" && /\[native code]/g.test(importScripts.toString())) {var __getWorkerSettings$ = function () {return null};try {importScripts((location.origin || (location.protocol + "//" + location.host)) + "/worker-hammerhead.js");} catch (e) {(async function () { await import((location.origin || (location.protocol + "//" + location.host)) + "/worker-hammerhead.js"); })();}}}/*hammerhead|script|processing-header-end*/
var someScript;

/*hammerhead|script|end*/</script>
Expand Down
Loading