poltergeist 1.7.0 → 1.8.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,31 @@
1
+ Poltergeist.Cmd = (function() {
2
+ function Cmd(owner, id, name, args) {
3
+ this.owner = owner;
4
+ this.id = id;
5
+ this.name = name;
6
+ this.args = args;
7
+ }
8
+
9
+ Cmd.prototype.sendResponse = function(response) {
10
+ var errors;
11
+ errors = this.browser.currentPage.errors;
12
+ this.browser.currentPage.clearErrors();
13
+ if (errors.length > 0 && this.browser.js_errors) {
14
+ return this.sendError(new Poltergeist.JavascriptError(errors));
15
+ } else {
16
+ return this.owner.sendResponse(this.id, response);
17
+ }
18
+ };
19
+
20
+ Cmd.prototype.sendError = function(errors) {
21
+ return this.owner.sendError(this.id, errors);
22
+ };
23
+
24
+ Cmd.prototype.run = function(browser) {
25
+ this.browser = browser;
26
+ return this.browser.runCommand(this);
27
+ };
28
+
29
+ return Cmd;
30
+
31
+ })();
@@ -1,10 +1,10 @@
1
- var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
1
+ var bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
2
2
 
3
3
  Poltergeist.Connection = (function() {
4
4
  function Connection(owner, port) {
5
5
  this.owner = owner;
6
6
  this.port = port;
7
- this.commandReceived = __bind(this.commandReceived, this);
7
+ this.commandReceived = bind(this.commandReceived, this);
8
8
  this.socket = new WebSocket("ws://127.0.0.1:" + this.port + "/");
9
9
  this.socket.onmessage = this.commandReceived;
10
10
  this.socket.onclose = function() {
@@ -1,11 +1,11 @@
1
- var Poltergeist, system, _ref, _ref1, _ref2,
2
- __hasProp = {}.hasOwnProperty,
3
- __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
1
+ var Poltergeist, system,
2
+ extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
3
+ hasProp = {}.hasOwnProperty;
4
4
 
5
5
  Poltergeist = (function() {
6
6
  function Poltergeist(port, width, height) {
7
7
  var that;
8
- this.browser = new Poltergeist.Browser(this, width, height);
8
+ this.browser = new Poltergeist.Browser(width, height);
9
9
  this.connection = new Poltergeist.Connection(this, port);
10
10
  that = this;
11
11
  phantom.onError = function(message, stack) {
@@ -15,28 +15,31 @@ Poltergeist = (function() {
15
15
  }
16
16
 
17
17
  Poltergeist.prototype.runCommand = function(command) {
18
- var error;
18
+ var error, error1;
19
19
  this.running = true;
20
+ command = new Poltergeist.Cmd(this, command.id, command.name, command.args);
20
21
  try {
21
- return this.browser.runCommand(command.name, command.args);
22
- } catch (_error) {
23
- error = _error;
22
+ return command.run(this.browser);
23
+ } catch (error1) {
24
+ error = error1;
24
25
  if (error instanceof Poltergeist.Error) {
25
- return this.sendError(error);
26
+ return this.sendError(command.id, error);
26
27
  } else {
27
- return this.sendError(new Poltergeist.BrowserError(error.toString(), error.stack));
28
+ return this.sendError(command.id, new Poltergeist.BrowserError(error.toString(), error.stack));
28
29
  }
29
30
  }
30
31
  };
31
32
 
32
- Poltergeist.prototype.sendResponse = function(response) {
33
+ Poltergeist.prototype.sendResponse = function(command_id, response) {
33
34
  return this.send({
35
+ command_id: command_id,
34
36
  response: response
35
37
  });
36
38
  };
37
39
 
38
- Poltergeist.prototype.sendError = function(error) {
40
+ Poltergeist.prototype.sendError = function(command_id, error) {
39
41
  return this.send({
42
+ command_id: command_id,
40
43
  error: {
41
44
  name: error.name || 'Generic',
42
45
  args: error.args && error.args() || [error.toString()]
@@ -64,12 +67,11 @@ Poltergeist.Error = (function() {
64
67
 
65
68
  })();
66
69
 
67
- Poltergeist.ObsoleteNode = (function(_super) {
68
- __extends(ObsoleteNode, _super);
70
+ Poltergeist.ObsoleteNode = (function(superClass) {
71
+ extend(ObsoleteNode, superClass);
69
72
 
70
73
  function ObsoleteNode() {
71
- _ref = ObsoleteNode.__super__.constructor.apply(this, arguments);
72
- return _ref;
74
+ return ObsoleteNode.__super__.constructor.apply(this, arguments);
73
75
  }
74
76
 
75
77
  ObsoleteNode.prototype.name = "Poltergeist.ObsoleteNode";
@@ -86,8 +88,8 @@ Poltergeist.ObsoleteNode = (function(_super) {
86
88
 
87
89
  })(Poltergeist.Error);
88
90
 
89
- Poltergeist.InvalidSelector = (function(_super) {
90
- __extends(InvalidSelector, _super);
91
+ Poltergeist.InvalidSelector = (function(superClass) {
92
+ extend(InvalidSelector, superClass);
91
93
 
92
94
  function InvalidSelector(method, selector) {
93
95
  this.method = method;
@@ -104,8 +106,8 @@ Poltergeist.InvalidSelector = (function(_super) {
104
106
 
105
107
  })(Poltergeist.Error);
106
108
 
107
- Poltergeist.FrameNotFound = (function(_super) {
108
- __extends(FrameNotFound, _super);
109
+ Poltergeist.FrameNotFound = (function(superClass) {
110
+ extend(FrameNotFound, superClass);
109
111
 
110
112
  function FrameNotFound(frameName) {
111
113
  this.frameName = frameName;
@@ -121,8 +123,8 @@ Poltergeist.FrameNotFound = (function(_super) {
121
123
 
122
124
  })(Poltergeist.Error);
123
125
 
124
- Poltergeist.MouseEventFailed = (function(_super) {
125
- __extends(MouseEventFailed, _super);
126
+ Poltergeist.MouseEventFailed = (function(superClass) {
127
+ extend(MouseEventFailed, superClass);
126
128
 
127
129
  function MouseEventFailed(eventName, selector, position) {
128
130
  this.eventName = eventName;
@@ -140,8 +142,8 @@ Poltergeist.MouseEventFailed = (function(_super) {
140
142
 
141
143
  })(Poltergeist.Error);
142
144
 
143
- Poltergeist.JavascriptError = (function(_super) {
144
- __extends(JavascriptError, _super);
145
+ Poltergeist.JavascriptError = (function(superClass) {
146
+ extend(JavascriptError, superClass);
145
147
 
146
148
  function JavascriptError(errors) {
147
149
  this.errors = errors;
@@ -157,12 +159,12 @@ Poltergeist.JavascriptError = (function(_super) {
157
159
 
158
160
  })(Poltergeist.Error);
159
161
 
160
- Poltergeist.BrowserError = (function(_super) {
161
- __extends(BrowserError, _super);
162
+ Poltergeist.BrowserError = (function(superClass) {
163
+ extend(BrowserError, superClass);
162
164
 
163
- function BrowserError(message, stack) {
164
- this.message = message;
165
- this.stack = stack;
165
+ function BrowserError(message1, stack1) {
166
+ this.message = message1;
167
+ this.stack = stack1;
166
168
  }
167
169
 
168
170
  BrowserError.prototype.name = "Poltergeist.BrowserError";
@@ -175,30 +177,28 @@ Poltergeist.BrowserError = (function(_super) {
175
177
 
176
178
  })(Poltergeist.Error);
177
179
 
178
- Poltergeist.StatusFailError = (function(_super) {
179
- __extends(StatusFailError, _super);
180
+ Poltergeist.StatusFailError = (function(superClass) {
181
+ extend(StatusFailError, superClass);
180
182
 
181
- function StatusFailError() {
182
- _ref1 = StatusFailError.__super__.constructor.apply(this, arguments);
183
- return _ref1;
183
+ function StatusFailError(url) {
184
+ this.url = url;
184
185
  }
185
186
 
186
187
  StatusFailError.prototype.name = "Poltergeist.StatusFailError";
187
188
 
188
189
  StatusFailError.prototype.args = function() {
189
- return [];
190
+ return [this.url];
190
191
  };
191
192
 
192
193
  return StatusFailError;
193
194
 
194
195
  })(Poltergeist.Error);
195
196
 
196
- Poltergeist.NoSuchWindowError = (function(_super) {
197
- __extends(NoSuchWindowError, _super);
197
+ Poltergeist.NoSuchWindowError = (function(superClass) {
198
+ extend(NoSuchWindowError, superClass);
198
199
 
199
200
  function NoSuchWindowError() {
200
- _ref2 = NoSuchWindowError.__super__.constructor.apply(this, arguments);
201
- return _ref2;
201
+ return NoSuchWindowError.__super__.constructor.apply(this, arguments);
202
202
  }
203
203
 
204
204
  NoSuchWindowError.prototype.name = "Poltergeist.NoSuchWindowError";
@@ -211,13 +211,15 @@ Poltergeist.NoSuchWindowError = (function(_super) {
211
211
 
212
212
  })(Poltergeist.Error);
213
213
 
214
- phantom.injectJs("" + phantom.libraryPath + "/web_page.js");
214
+ phantom.injectJs(phantom.libraryPath + "/web_page.js");
215
+
216
+ phantom.injectJs(phantom.libraryPath + "/node.js");
215
217
 
216
- phantom.injectJs("" + phantom.libraryPath + "/node.js");
218
+ phantom.injectJs(phantom.libraryPath + "/connection.js");
217
219
 
218
- phantom.injectJs("" + phantom.libraryPath + "/connection.js");
220
+ phantom.injectJs(phantom.libraryPath + "/cmd.js");
219
221
 
220
- phantom.injectJs("" + phantom.libraryPath + "/browser.js");
222
+ phantom.injectJs(phantom.libraryPath + "/browser.js");
221
223
 
222
224
  system = require('system');
223
225
 
@@ -1,10 +1,9 @@
1
- var __slice = [].slice;
1
+ var slice = [].slice;
2
2
 
3
3
  Poltergeist.Node = (function() {
4
- var name, _fn, _i, _len, _ref,
5
- _this = this;
4
+ var fn, i, len, name, ref;
6
5
 
7
- Node.DELEGATES = ['allText', 'visibleText', 'getAttribute', 'value', 'set', 'setAttribute', 'isObsolete', 'removeAttribute', 'isMultiple', 'select', 'tagName', 'find', 'getAttributes', 'isVisible', 'position', 'trigger', 'parentId', 'parentIds', 'mouseEventTest', 'scrollIntoView', 'isDOMEqual', 'isDisabled', 'deleteText', 'containsSelection', 'path'];
6
+ Node.DELEGATES = ['allText', 'visibleText', 'getAttribute', 'value', 'set', 'setAttribute', 'isObsolete', 'removeAttribute', 'isMultiple', 'select', 'tagName', 'find', 'getAttributes', 'isVisible', 'isInViewport', 'position', 'trigger', 'parentId', 'parentIds', 'mouseEventTest', 'scrollIntoView', 'isDOMEqual', 'isDisabled', 'deleteText', 'containsSelection', 'path', 'getProperty'];
8
7
 
9
8
  function Node(page, id) {
10
9
  this.page = page;
@@ -15,17 +14,17 @@ Poltergeist.Node = (function() {
15
14
  return new Poltergeist.Node(this.page, this.parentId());
16
15
  };
17
16
 
18
- _ref = Node.DELEGATES;
19
- _fn = function(name) {
17
+ ref = Node.DELEGATES;
18
+ fn = function(name) {
20
19
  return Node.prototype[name] = function() {
21
20
  var args;
22
- args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
21
+ args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
23
22
  return this.page.nodeCall(this.id, name, args);
24
23
  };
25
24
  };
26
- for (_i = 0, _len = _ref.length; _i < _len; _i++) {
27
- name = _ref[_i];
28
- _fn(name);
25
+ for (i = 0, len = ref.length; i < len; i++) {
26
+ name = ref[i];
27
+ fn(name);
29
28
  }
30
29
 
31
30
  Node.prototype.mouseEventPosition = function() {
@@ -86,4 +85,4 @@ Poltergeist.Node = (function() {
86
85
 
87
86
  return Node;
88
87
 
89
- }).call(this);
88
+ })();
@@ -1,9 +1,8 @@
1
- var __slice = [].slice,
2
- __indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
1
+ var slice = [].slice,
2
+ indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
3
3
 
4
4
  Poltergeist.WebPage = (function() {
5
- var command, delegate, _fn, _fn1, _i, _j, _len, _len1, _ref, _ref1,
6
- _this = this;
5
+ var command, delegate, fn1, fn2, i, j, len, len1, ref, ref1;
7
6
 
8
7
  WebPage.CALLBACKS = ['onConsoleMessage', 'onLoadFinished', 'onInitialized', 'onLoadStarted', 'onResourceRequested', 'onResourceReceived', 'onError', 'onNavigationRequested', 'onUrlChanged', 'onPageCreated', 'onClosing'];
9
8
 
@@ -14,7 +13,7 @@ Poltergeist.WebPage = (function() {
14
13
  WebPage.EXTENSIONS = [];
15
14
 
16
15
  function WebPage(_native) {
17
- var callback, _i, _len, _ref;
16
+ var callback, i, len, ref;
18
17
  this._native = _native;
19
18
  this._native || (this._native = require('webpage').create());
20
19
  this.id = 0;
@@ -27,35 +26,35 @@ Poltergeist.WebPage = (function() {
27
26
  this._networkTraffic = {};
28
27
  this._tempHeaders = {};
29
28
  this._blockedUrls = [];
30
- _ref = WebPage.CALLBACKS;
31
- for (_i = 0, _len = _ref.length; _i < _len; _i++) {
32
- callback = _ref[_i];
29
+ ref = WebPage.CALLBACKS;
30
+ for (i = 0, len = ref.length; i < len; i++) {
31
+ callback = ref[i];
33
32
  this.bindCallback(callback);
34
33
  }
35
34
  }
36
35
 
37
- _ref = WebPage.COMMANDS;
38
- _fn = function(command) {
36
+ ref = WebPage.COMMANDS;
37
+ fn1 = function(command) {
39
38
  return WebPage.prototype[command] = function() {
40
39
  var args;
41
- args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
40
+ args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
42
41
  return this.runCommand(command, args);
43
42
  };
44
43
  };
45
- for (_i = 0, _len = _ref.length; _i < _len; _i++) {
46
- command = _ref[_i];
47
- _fn(command);
44
+ for (i = 0, len = ref.length; i < len; i++) {
45
+ command = ref[i];
46
+ fn1(command);
48
47
  }
49
48
 
50
- _ref1 = WebPage.DELEGATES;
51
- _fn1 = function(delegate) {
49
+ ref1 = WebPage.DELEGATES;
50
+ fn2 = function(delegate) {
52
51
  return WebPage.prototype[delegate] = function() {
53
52
  return this._native[delegate].apply(this._native, arguments);
54
53
  };
55
54
  };
56
- for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
57
- delegate = _ref1[_j];
58
- _fn1(delegate);
55
+ for (j = 0, len1 = ref1.length; j < len1; j++) {
56
+ delegate = ref1[j];
57
+ fn2(delegate);
59
58
  }
60
59
 
61
60
  WebPage.prototype.onInitializedNative = function() {
@@ -111,18 +110,18 @@ Poltergeist.WebPage = (function() {
111
110
  };
112
111
 
113
112
  WebPage.prototype.onResourceRequestedNative = function(request, net) {
114
- var abort, _ref2;
113
+ var abort, ref2;
115
114
  abort = this.urlBlacklist.some(function(blacklisted_url) {
116
115
  return request.url.indexOf(blacklisted_url) !== -1;
117
116
  });
118
117
  if (abort) {
119
- if (_ref2 = request.url, __indexOf.call(this._blockedUrls, _ref2) < 0) {
118
+ if (ref2 = request.url, indexOf.call(this._blockedUrls, ref2) < 0) {
120
119
  this._blockedUrls.push(request.url);
121
120
  }
122
121
  return net.abort();
123
122
  } else {
124
123
  this.lastRequestId = request.id;
125
- if (request.url === this.redirectURL) {
124
+ if (this.normalizeURL(request.url) === this.redirectURL) {
126
125
  this.redirectURL = null;
127
126
  this.requestId = request.id;
128
127
  }
@@ -134,13 +133,13 @@ Poltergeist.WebPage = (function() {
134
133
  };
135
134
 
136
135
  WebPage.prototype.onResourceReceivedNative = function(response) {
137
- var _ref2;
138
- if ((_ref2 = this._networkTraffic[response.id]) != null) {
139
- _ref2.responseParts.push(response);
136
+ var ref2;
137
+ if ((ref2 = this._networkTraffic[response.id]) != null) {
138
+ ref2.responseParts.push(response);
140
139
  }
141
140
  if (this.requestId === response.id) {
142
141
  if (response.redirectURL) {
143
- return this.redirectURL = response.redirectURL;
142
+ return this.redirectURL = this.normalizeURL(response.redirectURL);
144
143
  } else {
145
144
  this.statusCode = response.status;
146
145
  return this._responseHeaders = response.headers;
@@ -149,18 +148,18 @@ Poltergeist.WebPage = (function() {
149
148
  };
150
149
 
151
150
  WebPage.prototype.injectAgent = function() {
152
- var extension, _k, _len2, _ref2, _results;
151
+ var extension, k, len2, ref2, results;
153
152
  if (this["native"]().evaluate(function() {
154
153
  return typeof __poltergeist;
155
154
  }) === "undefined") {
156
- this["native"]().injectJs("" + phantom.libraryPath + "/agent.js");
157
- _ref2 = WebPage.EXTENSIONS;
158
- _results = [];
159
- for (_k = 0, _len2 = _ref2.length; _k < _len2; _k++) {
160
- extension = _ref2[_k];
161
- _results.push(this["native"]().injectJs(extension));
155
+ this["native"]().injectJs(phantom.libraryPath + "/agent.js");
156
+ ref2 = WebPage.EXTENSIONS;
157
+ results = [];
158
+ for (k = 0, len2 = ref2.length; k < len2; k++) {
159
+ extension = ref2[k];
160
+ results.push(this["native"]().injectJs(extension));
162
161
  }
163
- return _results;
162
+ return results;
164
163
  }
165
164
  };
166
165
 
@@ -195,20 +194,22 @@ Poltergeist.WebPage = (function() {
195
194
  };
196
195
 
197
196
  WebPage.prototype.keyModifierKeys = function(names) {
198
- var _this = this;
199
- return names.split(',').map(function(name) {
200
- return _this.keyCode(name.charAt(0).toUpperCase() + name.substring(1));
201
- });
197
+ return names.split(',').map((function(_this) {
198
+ return function(name) {
199
+ return _this.keyCode(name.charAt(0).toUpperCase() + name.substring(1));
200
+ };
201
+ })(this));
202
202
  };
203
203
 
204
204
  WebPage.prototype.waitState = function(state, callback) {
205
- var _this = this;
206
205
  if (this.state === state) {
207
206
  return callback.call();
208
207
  } else {
209
- return setTimeout((function() {
210
- return _this.waitState(state, callback);
211
- }), 100);
208
+ return setTimeout(((function(_this) {
209
+ return function() {
210
+ return _this.waitState(state, callback);
211
+ };
212
+ })(this)), 100);
212
213
  }
213
214
  };
214
215
 
@@ -241,13 +242,13 @@ Poltergeist.WebPage = (function() {
241
242
  return this["native"]().frameTitle;
242
243
  };
243
244
 
244
- WebPage.prototype.frameUrl = function(frameName) {
245
+ WebPage.prototype.frameUrl = function(frameNameOrId) {
245
246
  var query;
246
- query = function(frameName) {
247
- var _ref2;
248
- return (_ref2 = document.querySelector("iframe[name='" + frameName + "']")) != null ? _ref2.src : void 0;
247
+ query = function(frameNameOrId) {
248
+ var ref2;
249
+ return (ref2 = document.querySelector("iframe[name='" + frameNameOrId + "'], iframe[id='" + frameNameOrId + "']")) != null ? ref2.src : void 0;
249
250
  };
250
- return this.evaluate(query, frameName);
251
+ return this.evaluate(query, frameNameOrId);
251
252
  };
252
253
 
253
254
  WebPage.prototype.clearErrors = function() {
@@ -322,32 +323,53 @@ Poltergeist.WebPage = (function() {
322
323
  };
323
324
 
324
325
  WebPage.prototype.addTempHeader = function(header) {
325
- var name, value, _results;
326
- _results = [];
326
+ var name, results, value;
327
+ results = [];
327
328
  for (name in header) {
328
329
  value = header[name];
329
- _results.push(this._tempHeaders[name] = value);
330
+ results.push(this._tempHeaders[name] = value);
330
331
  }
331
- return _results;
332
+ return results;
332
333
  };
333
334
 
334
335
  WebPage.prototype.removeTempHeaders = function() {
335
- var allHeaders, name, value, _ref2;
336
+ var allHeaders, name, ref2, value;
336
337
  allHeaders = this.getCustomHeaders();
337
- _ref2 = this._tempHeaders;
338
- for (name in _ref2) {
339
- value = _ref2[name];
338
+ ref2 = this._tempHeaders;
339
+ for (name in ref2) {
340
+ value = ref2[name];
340
341
  delete allHeaders[name];
341
342
  }
342
343
  return this.setCustomHeaders(allHeaders);
343
344
  };
344
345
 
345
346
  WebPage.prototype.pushFrame = function(name) {
347
+ var frame_no;
346
348
  if (this["native"]().switchToFrame(name)) {
347
349
  this.frames.push(name);
348
350
  return true;
349
351
  } else {
350
- return false;
352
+ frame_no = this["native"]().evaluate(function(frame_name) {
353
+ var f, frames, idx;
354
+ frames = document.querySelectorAll("iframe, frame");
355
+ return ((function() {
356
+ var k, len2, results;
357
+ results = [];
358
+ for (idx = k = 0, len2 = frames.length; k < len2; idx = ++k) {
359
+ f = frames[idx];
360
+ if ((f != null ? f['name'] : void 0) === frame_name || (f != null ? f['id'] : void 0) === frame_name) {
361
+ results.push(idx);
362
+ }
363
+ }
364
+ return results;
365
+ })())[0];
366
+ }, name);
367
+ if ((frame_no != null) && this["native"]().switchToFrame(frame_no)) {
368
+ this.frames.push(name);
369
+ return true;
370
+ } else {
371
+ return false;
372
+ }
351
373
  }
352
374
  };
353
375
 
@@ -403,7 +425,7 @@ Poltergeist.WebPage = (function() {
403
425
 
404
426
  WebPage.prototype.evaluate = function() {
405
427
  var args, fn;
406
- fn = arguments[0], args = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
428
+ fn = arguments[0], args = 2 <= arguments.length ? slice.call(arguments, 1) : [];
407
429
  this.injectAgent();
408
430
  return JSON.parse(this.sanitize(this["native"]().evaluate("function() { return PoltergeistAgent.stringify(" + (this.stringifyCall(fn, args)) + ") }")));
409
431
  };
@@ -418,7 +440,7 @@ Poltergeist.WebPage = (function() {
418
440
 
419
441
  WebPage.prototype.execute = function() {
420
442
  var args, fn;
421
- fn = arguments[0], args = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
443
+ fn = arguments[0], args = 2 <= arguments.length ? slice.call(arguments, 1) : [];
422
444
  return this["native"]().evaluate("function() { " + (this.stringifyCall(fn, args)) + " }");
423
445
  };
424
446
 
@@ -426,7 +448,7 @@ Poltergeist.WebPage = (function() {
426
448
  if (args.length === 0) {
427
449
  return "(" + (fn.toString()) + ")()";
428
450
  } else {
429
- return "(" + (fn.toString()) + ").apply(this, JSON.parse(" + (JSON.stringify(JSON.stringify(args))) + "))";
451
+ return "(" + (fn.toString()) + ").apply(this, PoltergeistAgent.JSON.parse(" + (JSON.stringify(JSON.stringify(args))) + "))";
430
452
  }
431
453
  };
432
454
 
@@ -476,6 +498,13 @@ Poltergeist.WebPage = (function() {
476
498
  return this["native"]().canGoForward;
477
499
  };
478
500
 
501
+ WebPage.prototype.normalizeURL = function(url) {
502
+ var parser;
503
+ parser = document.createElement('a');
504
+ parser.href = url;
505
+ return parser.href;
506
+ };
507
+
479
508
  return WebPage;
480
509
 
481
- }).call(this);
510
+ })();