make sure window.promot doesn't get called, fixes #106
This commit is contained in:
parent
7587381e1e
commit
dfe1bece2c
9
Gemfile
9
Gemfile
@ -12,6 +12,15 @@ gem 'guard-shell'
|
||||
gem 'guard-coffeescript'
|
||||
gem 'guard-cucumber'
|
||||
|
||||
require 'rbconfig'
|
||||
case RbConfig::CONFIG['host_os']
|
||||
when /darwin/
|
||||
gem 'growl'
|
||||
gem 'rb-fsevent'
|
||||
when /linux/
|
||||
gem 'libnotify'
|
||||
end
|
||||
|
||||
gem 'growl'
|
||||
gem 'rake', '0.8.7'
|
||||
gem 'mocha', '0.9.12'
|
||||
|
@ -11,6 +11,5 @@ void Page::javaScriptConsoleMessage(const QString & message, int lineNumber, con
|
||||
}
|
||||
|
||||
void Page::javaScriptAlert(QWebFrame *, const QString &) {}
|
||||
bool Page::javaScriptConfirm(QWebFrame *, const QString &) {
|
||||
return false;
|
||||
}
|
||||
bool Page::javaScriptConfirm(QWebFrame *, const QString &) { return false; }
|
||||
bool Page::javaScriptPrompt(QWebFrame *, const QString &, const QString &, QString *) { return false; }
|
||||
|
@ -12,6 +12,7 @@ class Page: public QWebPage {
|
||||
void javaScriptConsoleMessage(const QString & message, int lineNumber, const QString & sourceID);
|
||||
void javaScriptAlert(QWebFrame *, const QString &);
|
||||
bool javaScriptConfirm(QWebFrame *, const QString &);
|
||||
bool javaScriptPrompt(QWebFrame *, const QString &, const QString &, QString *);
|
||||
signals:
|
||||
void handleError(const QString & message, int lineNumber, const QString & sourceID);
|
||||
};
|
||||
|
7
features/bin/with_window_prompt.feature
Normal file
7
features/bin/with_window_prompt.feature
Normal file
@ -0,0 +1,7 @@
|
||||
Feature: Bin - With window.prompt()
|
||||
Scenario: Alert the user that window.prompt() needs to be stubbed
|
||||
Given I have a test suite
|
||||
When I run `bin/jasmine-headless-webkit -j spec/jasmine/window_prompt/window_prompt.yml`
|
||||
Then the exit status should be 0
|
||||
And the output should include "You should mock window.prompt"
|
||||
|
2
spec/jasmine/window_prompt/source.js
Normal file
2
spec/jasmine/window_prompt/source.js
Normal file
@ -0,0 +1,2 @@
|
||||
window.prompt("Yes! Hi!");
|
||||
|
4
spec/jasmine/window_prompt/window_prompt.yml
Normal file
4
spec/jasmine/window_prompt/window_prompt.yml
Normal file
@ -0,0 +1,4 @@
|
||||
src_dir: spec/jasmine/window_prompt
|
||||
src_files:
|
||||
- '**/*.js'
|
||||
|
9
vendor/assets/coffeescripts/prolog.coffee
vendored
9
vendor/assets/coffeescripts/prolog.coffee
vendored
@ -48,8 +48,13 @@ if window.JHW
|
||||
false
|
||||
|
||||
# dialogs
|
||||
window.confirm = (message) ->
|
||||
puts "#{"[confirm]".foreground('red')} jasmine-headless-webkit can't handle confirm() yet! You should mock window.confirm. Returning true."
|
||||
window.confirm = ->
|
||||
puts "#{"[confirm]".foreground('red')} You should mock window.confirm. Returning true."
|
||||
|
||||
true
|
||||
|
||||
window.prompt = ->
|
||||
puts "#{"[prompt]".foreground('red')} You should mock window.prompt. Returning true."
|
||||
|
||||
true
|
||||
|
||||
|
20
vendor/assets/javascripts/prolog.js
vendored
20
vendor/assets/javascripts/prolog.js
vendored
@ -1,6 +1,5 @@
|
||||
(function() {
|
||||
var puts;
|
||||
|
||||
if (window.JHW) {
|
||||
window.console = {
|
||||
log: function(data) {
|
||||
@ -44,7 +43,9 @@
|
||||
e = e || window.event;
|
||||
JHW.hasError();
|
||||
puts("The code tried to leave the test page. Check for unhandled form submits and link clicks.");
|
||||
if (e) e.returnValue = 'string';
|
||||
if (e) {
|
||||
e.returnValue = 'string';
|
||||
}
|
||||
return 'string';
|
||||
};
|
||||
JHW._hasErrors = false;
|
||||
@ -53,8 +54,12 @@
|
||||
JHW._hasErrors = true;
|
||||
return false;
|
||||
};
|
||||
window.confirm = function(message) {
|
||||
puts("" + ("[confirm]".foreground('red')) + " jasmine-headless-webkit can't handle confirm() yet! You should mock window.confirm. Returning true.");
|
||||
window.confirm = function() {
|
||||
puts("" + ("[confirm]".foreground('red')) + " You should mock window.confirm. Returning true.");
|
||||
return true;
|
||||
};
|
||||
window.prompt = function() {
|
||||
puts("" + ("[prompt]".foreground('red')) + " You should mock window.prompt. Returning true.");
|
||||
return true;
|
||||
};
|
||||
window.alert = function(message) {
|
||||
@ -70,15 +75,14 @@
|
||||
_ref = jasmine.getEnv().reporter.subReporters_;
|
||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||
reporter = _ref[_i];
|
||||
if (reporter.consoleLogUsed != null) reporter.consoleLogUsed(msg);
|
||||
if (reporter.consoleLogUsed != null) {
|
||||
reporter.consoleLogUsed(msg);
|
||||
}
|
||||
}
|
||||
JHW._usedConsole = true;
|
||||
return puts(msg);
|
||||
};
|
||||
}
|
||||
|
||||
window.CoffeeScriptToFilename = {};
|
||||
|
||||
window.CSTF = window.CoffeeScriptToFilename;
|
||||
|
||||
}).call(this);
|
||||
|
Loading…
Reference in New Issue
Block a user