Add doubleclick event handling to pdfium_test_event_helper.cc As suggested on the referenced bug by reporter. Bug: chromium:1043510 Change-Id: I7d81240eee405fa24876f969472760e04638c2fa Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/65410 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
diff --git a/samples/pdfium_test_event_helper.cc b/samples/pdfium_test_event_helper.cc index 3e6f0ca..a3ddbef 100644 --- a/samples/pdfium_test_event_helper.cc +++ b/samples/pdfium_test_event_helper.cc
@@ -90,6 +90,24 @@ fprintf(stderr, "mouseup: bad button name\n"); } +void SendMouseDoubleClickEvent(FPDF_FORMHANDLE form, + FPDF_PAGE page, + const std::vector<std::string>& tokens) { + if (tokens.size() != 4 && tokens.size() != 5) { + fprintf(stderr, "mousedoubleclick: bad args\n"); + return; + } + + int x = atoi(tokens[2].c_str()); + int y = atoi(tokens[3].c_str()); + int modifiers = tokens.size() >= 5 ? GetModifiers(tokens[4]) : 0; + if (tokens[1] != "left") { + fprintf(stderr, "mousedoubleclick: bad button name\n"); + return; + } + FORM_OnLButtonDoubleClick(form, page, modifiers, x, y); +} + void SendMouseMoveEvent(FPDF_FORMHANDLE form, FPDF_PAGE page, const std::vector<std::string>& tokens) { @@ -134,6 +152,8 @@ SendMouseDownEvent(form, page, tokens); } else if (tokens[0] == "mouseup") { SendMouseUpEvent(form, page, tokens); + } else if (tokens[0] == "mousedoubleclick") { + SendMouseDoubleClickEvent(form, page, tokens); } else if (tokens[0] == "mousemove") { SendMouseMoveEvent(form, page, tokens); } else if (tokens[0] == "focus") {
diff --git a/testing/resources/javascript/mouse_events.evt b/testing/resources/javascript/mouse_events.evt index 68d7912..dc0105b 100644 --- a/testing/resources/javascript/mouse_events.evt +++ b/testing/resources/javascript/mouse_events.evt
@@ -8,6 +8,8 @@ # click left in field - has effect. mousedown,left,125,225 mouseup,left,125,225 +# Double-click in field - no effect. +mousedoubleclick,left,125,225 # Mouse out, click elsewhere. # This should trigger an On Blur event. (Bug 881) mousemove,125,100
diff --git a/testing/resources/javascript/mouse_events_expected.txt b/testing/resources/javascript/mouse_events_expected.txt index 2c88a82..531a38b 100644 --- a/testing/resources/javascript/mouse_events_expected.txt +++ b/testing/resources/javascript/mouse_events_expected.txt
@@ -21,6 +21,9 @@ Doc Submit Form: url=https://example.com + 19 data bytes: 6e 61 6d 65 3d 54 72 61 6c 66 61 7a 26 61 67 65 3d 31 32 Doc Print: 1, 0, 0, 0, 0, 0, 0, 0 +Alert: focus +Alert: PASS: this.submitForm blocked with Document.submitForm: User gesture required. +Alert: PASS: this.print blocked with Document.print: User gesture required. Alert: exit Alert: PASS: this.submitForm blocked with Document.submitForm: User gesture required. Alert: PASS: this.print blocked with Document.print: User gesture required.