1
1
describe ( 'angular.scenario.Application' , function ( ) {
2
+ var $window ;
2
3
var app , frames ;
3
4
4
5
function callLoadHandlers ( app ) {
@@ -52,61 +53,67 @@ describe('angular.scenario.Application', function() {
52
53
} ) ;
53
54
54
55
it ( 'should use a new iframe each time' , function ( ) {
55
- app . navigateTo ( 'about:blank ' ) ;
56
+ app . navigateTo ( 'http://localhost/ ' ) ;
56
57
var frame = app . getFrame_ ( ) ;
57
58
frame . attr ( 'test' , true ) ;
58
- app . navigateTo ( 'about:blank ' ) ;
59
+ app . navigateTo ( 'http://localhost/ ' ) ;
59
60
expect ( app . getFrame_ ( ) . attr ( 'test' ) ) . toBeFalsy ( ) ;
60
61
} ) ;
61
62
62
63
it ( 'should call error handler if document not accessible' , function ( ) {
64
+ var called ;
63
65
app . getWindow_ = function ( ) {
64
66
return { } ;
65
67
} ;
66
- app . navigateTo ( 'about:blank ' , angular . noop , function ( error ) {
68
+ app . navigateTo ( 'http://localhost/ ' , angular . noop , function ( error ) {
67
69
expect ( error ) . toMatch ( / S a n d b o x E r r o r / ) ;
70
+ called = true ;
68
71
} ) ;
69
72
callLoadHandlers ( app ) ;
73
+ expect ( called ) . toBeTruthy ( ) ;
70
74
} ) ;
71
75
72
- it ( 'should call error handler if using file:// URL' , function ( ) {
73
- app . navigateTo ( 'file://foo/bar.txt' , angular . noop , function ( error ) {
76
+ it ( 'should call error handler if navigating to about:blank' , function ( ) {
77
+ var called ;
78
+ app . navigateTo ( 'about:blank' , angular . noop , function ( error ) {
74
79
expect ( error ) . toMatch ( / S a n d b o x E r r o r / ) ;
80
+ called = true ;
75
81
} ) ;
82
+ expect ( called ) . toBeTruthy ( ) ;
76
83
} ) ;
77
84
78
85
it ( 'should call error handler if status check fails' , function ( ) {
79
86
app . checkUrlStatus_ = function ( url , callback ) {
80
87
callback . call ( this , 'Example Error' ) ;
81
88
} ;
82
- app . navigateTo ( 'about:blank ' , angular . noop , function ( error ) {
89
+ app . navigateTo ( 'http://localhost/ ' , angular . noop , function ( error ) {
83
90
expect ( error ) . toEqual ( 'Example Error' ) ;
84
91
} ) ;
85
92
} ) ;
86
93
87
94
it ( 'should hide old iframes and navigate to about:blank' , function ( ) {
88
- app . navigateTo ( 'about:blank #foo' ) ;
89
- app . navigateTo ( 'about:blank #bar' ) ;
95
+ app . navigateTo ( 'http://localhost/ #foo' ) ;
96
+ app . navigateTo ( 'http://localhost/ #bar' ) ;
90
97
var iframes = frames . find ( 'iframe' ) ;
91
98
expect ( iframes . length ) . toEqual ( 2 ) ;
92
99
expect ( iframes [ 0 ] . src ) . toEqual ( 'about:blank' ) ;
93
- expect ( iframes [ 1 ] . src ) . toEqual ( 'about:blank #bar' ) ;
100
+ expect ( iframes [ 1 ] . src ) . toEqual ( 'http://localhost/ #bar' ) ;
94
101
expect ( _jQuery ( iframes [ 0 ] ) . css ( 'display' ) ) . toEqual ( 'none' ) ;
95
102
} ) ;
96
103
97
104
it ( 'should URL update description bar' , function ( ) {
98
- app . navigateTo ( 'about:blank ' ) ;
105
+ app . navigateTo ( 'http://localhost/ ' ) ;
99
106
var anchor = frames . find ( '> h2 a' ) ;
100
- expect ( anchor . attr ( 'href' ) ) . toEqual ( 'about:blank ' ) ;
101
- expect ( anchor . text ( ) ) . toEqual ( 'about:blank ' ) ;
107
+ expect ( anchor . attr ( 'href' ) ) . toEqual ( 'http://localhost/ ' ) ;
108
+ expect ( anchor . text ( ) ) . toEqual ( 'http://localhost/ ' ) ;
102
109
} ) ;
103
110
104
111
it ( 'should call onload handler when frame loads' , function ( ) {
105
112
var called ;
106
113
app . getWindow_ = function ( ) {
107
114
return { document : { } } ;
108
115
} ;
109
- app . navigateTo ( 'about:blank ' , function ( $window , $document ) {
116
+ app . navigateTo ( 'http://localhost/ ' , function ( $window , $document ) {
110
117
called = true ;
111
118
} ) ;
112
119
callLoadHandlers ( app ) ;
@@ -130,7 +137,7 @@ describe('angular.scenario.Application', function() {
130
137
notifyWhenNoOutstandingRequests : function ( fn ) {
131
138
handlers . push ( fn ) ;
132
139
}
133
- }
140
+ } ;
134
141
} ;
135
142
app . getWindow_ = function ( ) {
136
143
return testWindow ;
@@ -173,35 +180,35 @@ describe('angular.scenario.Application', function() {
173
180
expect ( options . type ) . toEqual ( 'HEAD' ) ;
174
181
expect ( options . url ) . toEqual ( 'http://www.google.com/' ) ;
175
182
} ) ;
176
-
183
+
177
184
it ( 'should call error handler if status code is less than 200' , function ( ) {
178
185
var finished ;
179
186
response . status = 199 ;
180
187
response . statusText = 'Error Message' ;
181
- app . navigateTo ( 'about:blank ' , angular . noop , function ( error ) {
188
+ app . navigateTo ( 'http://localhost/ ' , angular . noop , function ( error ) {
182
189
expect ( error ) . toEqual ( '199 Error Message' ) ;
183
190
finished = true ;
184
191
} ) ;
185
192
expect ( finished ) . toBeTruthy ( ) ;
186
193
} ) ;
187
-
194
+
188
195
it ( 'should call error handler if status code is greater than 299' , function ( ) {
189
196
var finished ;
190
197
response . status = 300 ;
191
198
response . statusText = 'Error' ;
192
- app . navigateTo ( 'about:blank ' , angular . noop , function ( error ) {
199
+ app . navigateTo ( 'http://localhost/ ' , angular . noop , function ( error ) {
193
200
expect ( error ) . toEqual ( '300 Error' ) ;
194
201
finished = true ;
195
202
} ) ;
196
203
expect ( finished ) . toBeTruthy ( ) ;
197
204
} ) ;
198
-
205
+
199
206
it ( 'should call error handler if status code is 0 for sandbox error' , function ( ) {
200
207
var finished ;
201
208
response . status = 0 ;
202
209
response . statusText = '' ;
203
- app . navigateTo ( 'about:blank ' , angular . noop , function ( error ) {
204
- expect ( error ) . toEqual ( 'Sandbox Error: Cannot access about:blank ' ) ;
210
+ app . navigateTo ( 'http://localhost/ ' , angular . noop , function ( error ) {
211
+ expect ( error ) . toEqual ( 'Sandbox Error: Cannot access http://localhost/ ' ) ;
205
212
finished = true ;
206
213
} ) ;
207
214
expect ( finished ) . toBeTruthy ( ) ;
0 commit comments