Skip to content

fix(content): only remove .fbc-wrapper when one already existed - #1014

Open
SAY-5 wants to merge 1 commit into
mozilla:mainfrom
SAY-5:fix/issue-1008-fbc-wrapper-null-remove
Open

fix(content): only remove .fbc-wrapper when one already existed#1014
SAY-5 wants to merge 1 commit into
mozilla:mainfrom
SAY-5:fix/issue-1008-fbc-wrapper-null-remove

Conversation

@SAY-5

@SAY-5 SAY-5 commented Apr 30, 2026

Copy link
Copy Markdown

Summary

Closes #1008.

openInputPrompt queries for an existing .fbc-wrapper and, when one is missing, injects a fresh wrapper into the page. The trailing call

hasFbcWrapper.remove();

was placed outside the if/else block, so it ran unconditionally, including on the first badge click of a page when no wrapper existed and one was just created. The result was

TypeError: hasFbcWrapper is null
    at openInputPrompt (src/content_script.js:331)

and the prompt failed to open until a second click rebuilt the missing branch.

Fix

Move hasFbcWrapper.remove() into an else branch so it only runs when an existing wrapper is being torn down to make room for the new injection.

if (!hasFbcWrapper) {
    document.body.appendChild(injectIframeOntoPage(...));
    ...
} else {
    hasFbcWrapper.remove();
}

Test plan

  • node -c src/content_script.js, passes
  • Manual: load the extension, click any Facebook login badge as the very first interaction on a fresh page, confirm the in-page prompt opens without a console TypeError

openInputPrompt's hasFbcWrapper.remove() ran unconditionally outside
the if/else block, so the very first badge click on a page — when
no wrapper had been injected yet and one was just created — threw

  TypeError: hasFbcWrapper is null

at content_script.js:331 and the prompt failed to open until a
second click rebuilt the missing branch. Move the remove() into an
else branch so it only runs when an existing wrapper is being torn
down to make room for the new one.

Closes mozilla#1008.

Signed-off-by: SAY-5 <say.apm35@gmail.com>
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.

openInputPrompt crashes with TypeError on every first badge click

1 participant