Skip to content

Commit

Permalink
Support multi-line prompt messages
Browse files Browse the repository at this point in the history
  • Loading branch information
mhoran committed Jan 3, 2013
1 parent 2f9d76b commit 8a8d12a
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lib/capybara/webkit/browser.rb
Expand Up @@ -59,7 +59,7 @@ def confirm_messages
end

def prompt_messages
command("JavascriptPromptMessages").split("\n")
JSON.parse(command("JavascriptPromptMessages"))
end

def response_headers
Expand Down
6 changes: 6 additions & 0 deletions spec/driver_spec.rb
Expand Up @@ -700,6 +700,12 @@ def visit(url, driver=driver)
driver.find("//input").first.click
driver.console_messages.first[:message].should == "goodbye"
end

it "supports multi-line prompt messages" do
driver.execute_script("prompt('Hello\\nnewline')")
driver.prompt_messages.first.should == "Hello\nnewline"
end

end
end

Expand Down
5 changes: 4 additions & 1 deletion src/JavascriptPromptMessages.cpp
@@ -1,10 +1,13 @@
#include "JavascriptPromptMessages.h"
#include "WebPage.h"
#include "WebPageManager.h"
#include "JsonSerializer.h"

JavascriptPromptMessages::JavascriptPromptMessages(WebPageManager *manager, QStringList &arguments, QObject *parent) : SocketCommand(manager, arguments, parent) {}

void JavascriptPromptMessages::start()
{
emitFinished(true, page()->promptMessages());
JsonSerializer serializer;
QByteArray json = serializer.serialize(page()->promptMessages());
emitFinished(true, json);
}
4 changes: 2 additions & 2 deletions src/WebPage.cpp
Expand Up @@ -95,8 +95,8 @@ QVariantList WebPage::confirmMessages() {
return m_confirmMessages;
}

QString WebPage::promptMessages() {
return m_promptMessages.join("\n");
QVariantList WebPage::promptMessages() {
return m_promptMessages;
}

void WebPage::setUserAgent(QString userAgent) {
Expand Down
4 changes: 2 additions & 2 deletions src/WebPage.h
Expand Up @@ -26,7 +26,7 @@ class WebPage : public QWebPage {
QVariantList consoleMessages();
QVariantList alertMessages();
QVariantList confirmMessages();
QString promptMessages();
QVariantList promptMessages();
void resetWindowSize();
QWebPage *createWindow(WebWindowType type);
QString uuid();
Expand Down Expand Up @@ -75,7 +75,7 @@ class WebPage : public QWebPage {
QVariantList m_alertMessages;
QVariantList m_confirmMessages;
QString m_prompt_text;
QStringList m_promptMessages;
QVariantList m_promptMessages;
QString m_uuid;
WebPageManager *m_manager;
QString m_errorPageMessage;
Expand Down

0 comments on commit 8a8d12a

Please sign in to comment.