From bade0f6e5483a9d595782b2e95fc148ea2a55ee6 Mon Sep 17 00:00:00 2001 From: PavelMor25 <77216072+PavelMor25@users.noreply.github.com> Date: Thu, 23 Nov 2023 09:47:17 +0400 Subject: [PATCH] fix: processing script with private identifier (closes DevExpress/testcafe#8067) (#2979) * fix: private identifier * add ts-ignore * bump: esotope-hammerhead --- package-lock.json | 9 +++++---- package.json | 2 +- src/processing/script/transformers/property-get.ts | 5 +++++ .../sandbox/code-instrumentation/process-script-test.js | 2 +- 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/package-lock.json b/package-lock.json index cd1b4b3c4..106f74ac7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -15,7 +15,7 @@ "bowser": "1.6.0", "crypto-md5": "^1.0.0", "debug": "4.3.1", - "esotope-hammerhead": "0.6.6", + "esotope-hammerhead": "0.6.7", "http-cache-semantics": "^4.1.0", "httpntlm": "^1.8.10", "iconv-lite": "0.5.1", @@ -3788,9 +3788,10 @@ } }, "node_modules/esotope-hammerhead": { - "version": "0.6.6", - "resolved": "https://registry.npmjs.org/esotope-hammerhead/-/esotope-hammerhead-0.6.6.tgz", - "integrity": "sha512-pHTz6hKpCotF/VDMK6UlMo6A1Y8nQsYKuZPtNKWJSKWgvJvB35m91wqeSVz4TlkxTHyIfoeIwMiffdv7Z0JCRA==", + "version": "0.6.7", + "resolved": "https://github.com/PavelMor25/builds/raw/master/esotope-hammerhead-0.6.7.tgz", + "integrity": "sha512-argSa+sEtInDLFYPT4Tymawu0LHvmaUFShcjk54sxTkg6UBL0ux14lm4uommjXJkGk74E82ixQqE5p64gd25Yw==", + "license": "MIT", "dependencies": { "@types/estree": "0.0.46" } diff --git a/package.json b/package.json index 0bfb63506..5caceeaf1 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,7 @@ "bowser": "1.6.0", "crypto-md5": "^1.0.0", "debug": "4.3.1", - "esotope-hammerhead": "0.6.6", + "esotope-hammerhead": "0.6.7", "http-cache-semantics": "^4.1.0", "httpntlm": "^1.8.10", "iconv-lite": "0.5.1", diff --git a/src/processing/script/transformers/property-get.ts b/src/processing/script/transformers/property-get.ts index cb3c43cfa..c7e96ca64 100644 --- a/src/processing/script/transformers/property-get.ts +++ b/src/processing/script/transformers/property-get.ts @@ -32,6 +32,11 @@ const transformer: Transformer = { if (node.property.type === Syntax.Identifier && !shouldInstrumentProperty(node.property.name)) return false; + // Skip: object.#prop + // @ts-ignore + if (node.property.type === Syntax.PrivateIdentifier) + return false; + // Skip: super.prop if (node.object.type === Syntax.Super) return false; diff --git a/test/client/fixtures/sandbox/code-instrumentation/process-script-test.js b/test/client/fixtures/sandbox/code-instrumentation/process-script-test.js index bcd970a1b..6a7cd8b5f 100644 --- a/test/client/fixtures/sandbox/code-instrumentation/process-script-test.js +++ b/test/client/fixtures/sandbox/code-instrumentation/process-script-test.js @@ -235,7 +235,7 @@ if (!browserUtils.isIOS) { }); test('private identifier and property definition without value', function () { - var script = `const Nc = new class {#a; constructor(){this.#a = 4;}; output(){return this.#a;};}; window.prop = Nc.output()`; + var script = `class s{#a; constructor(){this.#a = 4;}; output(){return this.#a;};}; window.prop = new s().output()`; eval(processScript(script));