From a6521870515fdb9557049f73770e4f9f4ff7c437 Mon Sep 17 00:00:00 2001 From: AlexKamaev Date: Tue, 25 Oct 2022 13:15:18 +0400 Subject: [PATCH] add proxyless param to url-resolver (#2805) --- package.json | 2 +- src/client/index.ts | 1 + src/client/sandbox/index.ts | 9 ++------- src/client/utils/url-resolver.ts | 11 +++++++++++ 4 files changed, 15 insertions(+), 8 deletions(-) diff --git a/package.json b/package.json index 0296d0988..6b3c6edac 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "testcafe-hammerhead", "description": "A powerful web-proxy used as a core for the TestCafe testing framework (https://github.com/DevExpress/testcafe).", - "version": "28.0.0", + "version": "28.0.1", "homepage": "https://github.com/DevExpress/testcafe-hammerhead", "bugs": { "url": "https://github.com/DevExpress/testcafe-hammerhead/issues" diff --git a/src/client/index.ts b/src/client/index.ts index b02aa7171..1f6ba11f8 100644 --- a/src/client/index.ts +++ b/src/client/index.ts @@ -318,6 +318,7 @@ class Hammerhead { domProcessor.forceProxySrcForImage = initSettings.forceProxySrcForImage; domProcessor.allowMultipleWindows = initSettings.allowMultipleWindows; + urlResolver.proxyless = initSettings.proxyless; this.transport.start(this.eventSandbox.message, !initSettings.proxyless); this.sandbox.attach(this.win); diff --git a/src/client/sandbox/index.ts b/src/client/sandbox/index.ts index ac85f4d98..d95b47c02 100644 --- a/src/client/sandbox/index.ts +++ b/src/client/sandbox/index.ts @@ -143,7 +143,7 @@ export default class Sandbox extends SandboxBase { if (isIE) this.nativeMethods.refreshIfNecessary(document, window); - this._initUrlResolver(document); + urlResolver.init(document); this.event.reattach(window); this.shadowUI.attach(window); @@ -159,7 +159,7 @@ export default class Sandbox extends SandboxBase { nativeMethods.objectDefineProperty(window, INTERNAL_PROPS.sandboxIsReattached, { value: true, configurable: false }); - this._initUrlResolver(this.document); + urlResolver.init(this.document); // NOTE: Eval Hammerhead code script. this.iframe.on(this.iframe.EVAL_HAMMERHEAD_SCRIPT_EVENT, e => { @@ -208,11 +208,6 @@ export default class Sandbox extends SandboxBase { } } - private _initUrlResolver (document: Document) { - if (!this.proxyless) - urlResolver.init(document); - } - dispose (): void { this.event.hover.dispose(); this.event.focusBlur.dispose(); diff --git a/src/client/utils/url-resolver.ts b/src/client/utils/url-resolver.ts index 8fb8c60f1..f9eb4b125 100644 --- a/src/client/utils/url-resolver.ts +++ b/src/client/utils/url-resolver.ts @@ -74,6 +74,9 @@ export default { }, updateBase (url: string, doc: Document) { + if (this.proxyless) + return; + const resolverDocument = this._getResolver(doc); const baseElement = nativeMethods.elementGetElementsByTagName.call(resolverDocument.head, 'base')[0]; @@ -113,4 +116,12 @@ export default { dispose (doc) { doc[DOCUMENT_URL_RESOLVER] = null; }, + + get proxyless () { + return this._proxyless; + }, + + set proxyless (value: boolean) { + this._proxyless = value; + }, };