Skip to content

Commit 42e9ab4

Browse files
authored
Fix JS selector (#6992)
Task/Issue URL: https://app.asana.com/1/137249556945/project/1157893581871903/task/1211730035278177?focus=true ### Description Fix JS injection for text selector in Duck.ai ### Steps to test this PR _First open_ - [x] Fresh install, open Duck.ai without a prompt - [x] Verify Terms and Conditions dialog appears - [x] Accept them - [x] Verify Keyboard doesn’t appear - [x] Close Duck.ai (don’t hide the tips, we need them later) _Keyboard doesn’t open when Tips present_ - [x] Open Duck.ai without a prompt - [x] Verify keyboard doesn’t open - [x] Verify Tips are present - [x] Hide the tips - [x] Verify keyboard doesn’t appear - [x] Close Duck.ai _Keyboard opens when Tips are not present_ - [x] Open Duck.ai without a prompt - [x] Verify keyboard opens _Auto prompt_ - [x] Open Duck.ai with a prompt - [x] Verify keyboard doesn’t open
1 parent 4fdeb94 commit 42e9ab4

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

duckchat/duckchat-impl/src/main/java/com/duckduckgo/duckchat/impl/helper/DuckChatJSHelper.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ class RealDuckChatJSHelper @Inject constructor(
152152
): JsCallbackData {
153153
val jsonPayload =
154154
JSONObject().apply {
155-
val jsCall = "document.getElementsByName($selector)[0]?.focus();"
155+
val jsCall = "document.getElementsByName('$selector')[0]?.focus();"
156156
put(SELECTOR, jsCall)
157157
put(SUCCESS, true)
158158
put(ERROR, "")

duckchat/duckchat-impl/src/test/kotlin/com/duckduckgo/duckchat/impl/helper/RealDuckChatJSHelperTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,7 @@ class RealDuckChatJSHelperTest {
465465
val result = testee.processJsCallbackMessage(featureName, method, id, data)
466466

467467
val expectedPayload = JSONObject().apply {
468-
put("selector", "document.getElementsByName('user-prompt')[0]?.focus();")
468+
put("selector", "document.getElementsByName(''user-prompt'')[0]?.focus();")
469469
put("success", true)
470470
put("error", "")
471471
}

0 commit comments

Comments
 (0)