Skip to content
This repository
Browse code

Support multi-line prompt messages

  • Loading branch information...
commit 8a8d12af5cb644537f6220cd332cc916c4b1f5ef 1 parent 2f9d76b
Matthew Horan mhoran authored
2  lib/capybara/webkit/browser.rb
@@ -59,7 +59,7 @@ def confirm_messages
59 59 end
60 60
61 61 def prompt_messages
62   - command("JavascriptPromptMessages").split("\n")
  62 + JSON.parse(command("JavascriptPromptMessages"))
63 63 end
64 64
65 65 def response_headers
6 spec/driver_spec.rb
@@ -700,6 +700,12 @@ def visit(url, driver=driver)
700 700 driver.find("//input").first.click
701 701 driver.console_messages.first[:message].should == "goodbye"
702 702 end
  703 +
  704 + it "supports multi-line prompt messages" do
  705 + driver.execute_script("prompt('Hello\\nnewline')")
  706 + driver.prompt_messages.first.should == "Hello\nnewline"
  707 + end
  708 +
703 709 end
704 710 end
705 711
5 src/JavascriptPromptMessages.cpp
... ... @@ -1,10 +1,13 @@
1 1 #include "JavascriptPromptMessages.h"
2 2 #include "WebPage.h"
3 3 #include "WebPageManager.h"
  4 +#include "JsonSerializer.h"
4 5
5 6 JavascriptPromptMessages::JavascriptPromptMessages(WebPageManager *manager, QStringList &arguments, QObject *parent) : SocketCommand(manager, arguments, parent) {}
6 7
7 8 void JavascriptPromptMessages::start()
8 9 {
9   - emitFinished(true, page()->promptMessages());
  10 + JsonSerializer serializer;
  11 + QByteArray json = serializer.serialize(page()->promptMessages());
  12 + emitFinished(true, json);
10 13 }
4 src/WebPage.cpp
@@ -95,8 +95,8 @@ QVariantList WebPage::confirmMessages() {
95 95 return m_confirmMessages;
96 96 }
97 97
98   -QString WebPage::promptMessages() {
99   - return m_promptMessages.join("\n");
  98 +QVariantList WebPage::promptMessages() {
  99 + return m_promptMessages;
100 100 }
101 101
102 102 void WebPage::setUserAgent(QString userAgent) {
4 src/WebPage.h
@@ -26,7 +26,7 @@ class WebPage : public QWebPage {
26 26 QVariantList consoleMessages();
27 27 QVariantList alertMessages();
28 28 QVariantList confirmMessages();
29   - QString promptMessages();
  29 + QVariantList promptMessages();
30 30 void resetWindowSize();
31 31 QWebPage *createWindow(WebWindowType type);
32 32 QString uuid();
@@ -75,7 +75,7 @@ class WebPage : public QWebPage {
75 75 QVariantList m_alertMessages;
76 76 QVariantList m_confirmMessages;
77 77 QString m_prompt_text;
78   - QStringList m_promptMessages;
  78 + QVariantList m_promptMessages;
79 79 QString m_uuid;
80 80 WebPageManager *m_manager;
81 81 QString m_errorPageMessage;

0 comments on commit 8a8d12a

Please sign in to comment.
Something went wrong with that request. Please try again.