Skip to content

Commit 0d8189d

Browse files
authored
Merge pull request #190 from magento/MQE-1153
MQE-1153: ExecuteJS javascript escaping matches persisted data
2 parents df6aaf9 + a6bc047 commit 0d8189d

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
lines changed

dev/tests/verification/Resources/ExecuteJsEscapingTest.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,8 @@ class ExecuteJsEscapingTestCest
3131
{
3232
$javaVariableEscape = $I->executeJS("return \$javascriptVariable");
3333
$mftfVariableNotEscaped = $I->executeJS("return {$doNotEscape}");
34+
$persistedDataNotEscaped = $I->executeJS("return " . $persisted->getCreatedDataByName('data'));
35+
$hookPersistedDataNotEscaped = $I->executeJS("return " . $this->persisted->getCreatedDataByName('data'));
36+
$addNewAttributeForRule = $I->executeJS("document.querySelector('entity option[value=" . $this->productAttribute->getCreatedDataByName('attribute_code') . "]').setAttribute('selected', 'selected')");
3437
}
3538
}

dev/tests/verification/TestModule/Test/ExecuteJsTest.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,8 @@
1111
<test name="ExecuteJsEscapingTest">
1212
<executeJS function="return $javascriptVariable" stepKey="javaVariableEscape"/>
1313
<executeJS function="return {$doNotEscape}" stepKey="mftfVariableNotEscaped"/>
14+
<executeJS function="return $persisted.data$" stepKey="persistedDataNotEscaped"/>
15+
<executeJS function="return $$persisted.data$$" stepKey="hookPersistedDataNotEscaped"/>
16+
<executeJS function="document.querySelector('entity option[value=$$productAttribute.attribute_code$$]').setAttribute('selected', 'selected')" stepKey="addNewAttributeForRule"/>
1417
</test>
1518
</tests>

src/Magento/FunctionalTestingFramework/Util/TestGenerator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -624,7 +624,7 @@ public function generateStepsPhp($actionObjects, $hookObject = false, $actor = "
624624
}
625625
// turn $javaVariable => \$javaVariable but not {$mftfVariable}
626626
if ($actionObject->getType() == "executeJS") {
627-
$function = preg_replace('/(?<!{)(\$[\w\d_]+)/', '\\\\$1', $function);
627+
$function = preg_replace('/(?<!{)(\$[A-Za-z._]+)(?![A-z.]*+\$)/', '\\\\$1', $function);
628628
}
629629
}
630630

0 commit comments

Comments
 (0)