Skip to content

Commit

Permalink
add proxyless param to url-resolver (#2805)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexKamaev authored Oct 25, 2022
1 parent d556a60 commit a652187
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 8 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
1 change: 1 addition & 0 deletions src/client/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
9 changes: 2 additions & 7 deletions src/client/sandbox/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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 => {
Expand Down Expand Up @@ -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();
Expand Down
11 changes: 11 additions & 0 deletions src/client/utils/url-resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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];

Expand Down Expand Up @@ -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;
},
};

0 comments on commit a652187

Please sign in to comment.