watirsplash 2.2.0 → 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/Gemfile CHANGED
@@ -9,7 +9,7 @@ platforms :mingw, :mswin do
9
9
  end
10
10
 
11
11
  gem "watir-webdriver", WatirSplash::Version::WATIR_WEBDRIVER
12
- gem "firewatir", ">= 1.9.3"
12
+ gem "firewatir", ">= 1.9.4"
13
13
  gem "rspec", "~>2.6.0"
14
14
  gem "spork", "~>0.9.0.rc9"
15
15
 
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- watirsplash (2.1.1)
4
+ watirsplash (2.2.0)
5
5
  bundler (~> 1.0)
6
6
  rake (= 0.8.7)
7
7
  require_all
@@ -12,17 +12,18 @@ GEM
12
12
  remote: http://rubygems.org/
13
13
  specs:
14
14
  builder (3.0.0)
15
- childprocess (0.2.1)
15
+ childprocess (0.2.2)
16
16
  ffi (~> 1.0.6)
17
17
  commonwatir (2.0.1)
18
18
  user-choices
19
19
  diff-lcs (1.1.2)
20
20
  ffi (1.0.9-x86-mingw32)
21
- firewatir (1.9.3)
21
+ firewatir (1.9.4)
22
22
  commonwatir (>= 1.9.2)
23
23
  hoe (2.12.0)
24
24
  rake (~> 0.8)
25
- json_pure (1.5.3)
25
+ json_pure (1.5.4)
26
+ spruz (~> 0.2.8)
26
27
  mini_magick (3.2.1)
27
28
  subexec (~> 0.0.4)
28
29
  nokogiri (1.5.0-x86-mingw32)
@@ -40,13 +41,14 @@ GEM
40
41
  rubyzip (0.9.4)
41
42
  s4t-utils (1.0.4)
42
43
  hoe (>= 1.3.0)
43
- selenium-webdriver (2.4.0)
44
+ selenium-webdriver (2.5.0)
44
45
  childprocess (>= 0.2.1)
45
46
  ffi (>= 1.0.7)
46
47
  json_pure
47
48
  rubyzip
48
49
  spork (0.9.0.rc9-x86-mingw32)
49
50
  win32-process
51
+ spruz (0.2.13)
50
52
  subexec (0.0.4)
51
53
  syntax (1.0.0)
52
54
  thor (0.14.6)
@@ -61,7 +63,7 @@ GEM
61
63
  rautomation (~> 0.6.3)
62
64
  win32-process (>= 0.5.5)
63
65
  windows-pr (>= 0.6.6)
64
- watir-webdriver (0.3.1)
66
+ watir-webdriver (0.3.3)
65
67
  selenium-webdriver (>= 0.2.2)
66
68
  win32-api (1.4.8-x86-mingw32)
67
69
  win32-process (0.6.5)
@@ -81,10 +83,10 @@ PLATFORMS
81
83
  x86-mingw32
82
84
 
83
85
  DEPENDENCIES
84
- firewatir (>= 1.9.3)
86
+ firewatir (>= 1.9.4)
85
87
  rspec (~> 2.6.0)
86
88
  spork (~> 0.9.0.rc9)
87
89
  watir (= 2.0.1)
88
- watir-webdriver (~> 0.3.1)
90
+ watir-webdriver (~> 0.3.3)
89
91
  watirsplash!
90
92
  win32screenshot (~> 1.0.5)
data/History.rdoc CHANGED
@@ -1,3 +1,7 @@
1
+ === Version 2.3.0 / 2011-09-10
2
+
3
+ * add JavaScript errors detection for all supported frameworks & browsers - read more from wiki: https://github.com/jarmo/WatirSplash/wiki/Detecting-JavaScript-Errors
4
+
1
5
  === Version 2.2.0 / 2011-09-10
2
6
 
3
7
  * watir-webdriver/firefox is now the default framework under Linux and OS X
@@ -1,5 +1,32 @@
1
1
  module WatirSplash
2
+ class JavaScriptError < RuntimeError; end
3
+
2
4
  class Browser
5
+ # raises an error if any JavaScript errors were found
6
+ JAVASCRIPT_ERRORS_CHECKER = lambda do |browser|
7
+ error_message = browser.execute_script "#{browser.respond_to?(:driver) ? "return ": nil}window.__browserErrorMessage"
8
+
9
+ if error_message && !error_message.empty?
10
+ browser.execute_script "window.__browserErrorMessage = undefined"
11
+ raise JavaScriptError, "JavaScript error: #{error_message}"
12
+ end
13
+
14
+ browser.execute_script %q[
15
+ if (!window.onErrorFn) {
16
+ window.onErrorFn = function(errorMsg, url, lineNumber) {
17
+ window.__browserErrorMessage = errorMsg + " @ " + url + ":" + lineNumber;
18
+
19
+ if (window.__onErrorFn)
20
+ window.__onErrorFn(errorMsg, url, lineNumber);
21
+
22
+ return false;
23
+ };
24
+
25
+ window.__onErrorFn = window.onerror;
26
+ window.onerror = window.onErrorFn;
27
+ }]
28
+ end
29
+
3
30
  class << self
4
31
 
5
32
  attr_accessor :current
@@ -12,6 +39,7 @@ module WatirSplash
12
39
 
13
40
  def prepare browser
14
41
  self.current = browser
42
+ browser.add_checker JAVASCRIPT_ERRORS_CHECKER
15
43
  browser
16
44
  end
17
45
 
@@ -2,13 +2,6 @@ WatirSplash::Frameworks::Helper.load_gems "watir", "win32/screenshot"
2
2
  require "watirsplash/mini_magick_patch"
3
3
  require "watir/ie"
4
4
 
5
- module Watir
6
- module PageCheckers
7
- # raises an error if javascript error was found
8
- JAVASCRIPT_ERRORS_CHECKER = lambda {|ie| raise "Expected no JavaScript errors to appear on page, but having some!" if ie.status =~ /Error on page/}
9
- end
10
- end
11
-
12
5
  # patches for Watir
13
6
  module Watir
14
7
  class IE #:nodoc:all
@@ -17,8 +10,6 @@ module Watir
17
10
  def initialize suppress_new_window=nil
18
11
  _initialize suppress_new_window
19
12
  self.speed = :fast
20
- @error_checkers ||= []
21
- add_checker Watir::PageCheckers::JAVASCRIPT_ERRORS_CHECKER
22
13
  end
23
14
 
24
15
  def save_screenshot(params)
@@ -1,6 +1,6 @@
1
1
  module WatirSplash
2
2
  module Version
3
- WATIRSPLASH = "2.2.0"
3
+ WATIRSPLASH = "2.3.0"
4
4
 
5
5
  # possible runtime dependencies
6
6
  WATIR = "2.0.1"
data/spec/browser_spec.rb CHANGED
@@ -16,6 +16,21 @@ describe WatirSplash::Browser do
16
16
  browser.should == WatirSplash::Browser.current
17
17
  end
18
18
 
19
+ it "detects JavaScript errors" do
20
+ browser = WatirSplash::Browser.new
21
+ browser.goto "http://dl.dropbox.com/u/2731643/WatirSplash/test.html"
22
+ browser.execute_script("window.originalOnErrorExecuted").should_not be_true
23
+
24
+ expect {
25
+ browser.link(:id => "errorLink").click
26
+ }.to raise_error(WatirSplash::JavaScriptError, /JavaScript error:.*unexistingVar/)
27
+ browser.execute_script("window.originalOnErrorExecuted").should be_true
28
+
29
+ expect {
30
+ browser.link(:id => "toggle").click
31
+ }.not_to raise_error
32
+ end
33
+
19
34
  after :each do
20
35
  WatirSplash::Browser.current.close
21
36
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: watirsplash
3
3
  version: !ruby/object:Gem::Version
4
- hash: 7
4
+ hash: 3
5
5
  prerelease:
6
6
  segments:
7
7
  - 2
8
- - 2
8
+ - 3
9
9
  - 0
10
- version: 2.2.0
10
+ version: 2.3.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Jarmo Pertman
@@ -173,7 +173,7 @@ rubyforge_project:
173
173
  rubygems_version: 1.8.4
174
174
  signing_key:
175
175
  specification_version: 3
176
- summary: watirsplash 2.2.0
176
+ summary: watirsplash 2.3.0
177
177
  test_files:
178
178
  - spec/browser_spec.rb
179
179
  - spec/page_spec.rb