From c56b04a79e29f55d38c2d0b65e0b5a39fd056719 Mon Sep 17 00:00:00 2001 From: Andrei Oprea Date: Mon, 7 Jan 2019 09:35:24 +0000 Subject: [PATCH] Fix Bug 1515663 - Block FxA snippet on form submit (#4635) --- .../templates/SubmitFormSnippet/SubmitFormSnippet.jsx | 1 + test/unit/asrouter/templates/SubmitFormSnippet.test.jsx | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/content-src/asrouter/templates/SubmitFormSnippet/SubmitFormSnippet.jsx b/content-src/asrouter/templates/SubmitFormSnippet/SubmitFormSnippet.jsx index e06d66bc75..0ca26c0bcb 100644 --- a/content-src/asrouter/templates/SubmitFormSnippet/SubmitFormSnippet.jsx +++ b/content-src/asrouter/templates/SubmitFormSnippet/SubmitFormSnippet.jsx @@ -38,6 +38,7 @@ export class SubmitFormSnippet extends React.PureComponent { this.props.sendUserActionTelemetry({event: "CLICK_BUTTON", value: "conversion-subscribe-activation", id: "NEWTAB_FOOTER_BAR_CONTENT"}); if (this.props.form_method.toUpperCase() === "GET") { + this.props.onBlock({preventDismiss: true}); this.refs.form.submit(); return; } diff --git a/test/unit/asrouter/templates/SubmitFormSnippet.test.jsx b/test/unit/asrouter/templates/SubmitFormSnippet.test.jsx index cff62884c8..9c407094e9 100644 --- a/test/unit/asrouter/templates/SubmitFormSnippet.test.jsx +++ b/test/unit/asrouter/templates/SubmitFormSnippet.test.jsx @@ -249,5 +249,14 @@ describe("SubmitFormSnippet", () => { assert.notCalled(window.fetch); }); + it("should block the snippet when form_method is GET", () => { + wrapper.setProps({form_method: "GET"}); + wrapper.setState({expanded: true}); + + wrapper.instance().handleSubmit({preventDefault: sandbox.stub()}); + + assert.calledOnce(onBlockStub); + assert.calledWithExactly(onBlockStub, {preventDismiss: true}); + }); }); });