Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Harden _Q.push wrapper in the amzn_apstag.js shim #41

Merged
merged 1 commit into from
Mar 20, 2024

Conversation

kzar
Copy link
Contributor

@kzar kzar commented Mar 18, 2024

Apstag calls are queued onto the window.apstag._Q array and are then
called when the Apstag script is ready. The shim expects each queued
call to be an array containing the API method name prefix and
arguments, e.g.

["f", {slots: [...], timeout: 3000}, () => { ... }]

I noticed in practice however, some calls are queued differently, with a
queued call looking something like this instead:

[["f", Arguments([{slots: [...], timeout: 3000}, () => { ... }])]]

Since the original script handles that, the shim needs to as
well. Let's try our best here, without changing too much and risking
further breakage.

@kzar kzar requested a review from dharb March 18, 2024 18:27
@kzar kzar marked this pull request as draft March 19, 2024 10:06
@kzar kzar force-pushed the apstag-q-push branch 2 times, most recently from 576625b to 8de92a8 Compare March 19, 2024 17:14
@kzar kzar marked this pull request as ready for review March 19, 2024 17:16
@kzar kzar marked this pull request as draft March 19, 2024 17:32
@kzar kzar force-pushed the apstag-q-push branch 2 times, most recently from 6a126dd to 1000cfe Compare March 19, 2024 17:40
@kzar kzar marked this pull request as ready for review March 19, 2024 17:40
Apstag calls are queued onto the `window.apstag._Q` array and are then
called when the Apstag script is ready. The shim expects each queued
call to be an array containing the API method name prefix and
arguments, e.g.

    ["f", {slots: [...], timeout: 3000}, () => { ... }]

I noticed in practice however, some calls are queued differently, with a
queued call looking something like this instead:

    [["f", Arguments([{slots: [...], timeout: 3000}, () => { ... }])]]

Since the original script handles that, the shim needs to as
well. Let's try our best here, without changing too much and risking
further breakage.
Copy link
Collaborator

@dharb dharb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, thanks @kzar!

@dharb dharb merged commit 0242268 into duckduckgo:main Mar 20, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants