Skip to content
This repository has been archived by the owner on Nov 27, 2020. It is now read-only.

Commit

Permalink
Merge pull request #797 from twalpole/frame_cleanup
Browse files Browse the repository at this point in the history
Remove unused frames array  from Poltergeist.WebPage
  • Loading branch information
twalpole committed Jul 20, 2016
2 parents cca1000 + 0ece46f commit ae51ce7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 27 deletions.
11 changes: 1 addition & 10 deletions lib/capybara/poltergeist/client/compiled/web_page.js
Expand Up @@ -23,7 +23,6 @@ Poltergeist.WebPage = (function() {
this.state = 'default';
this.urlWhitelist = [];
this.urlBlacklist = [];
this.frames = [];
this.errors = [];
this._networkTraffic = {};
this._tempHeaders = {};
Expand Down Expand Up @@ -422,7 +421,6 @@ Poltergeist.WebPage = (function() {
WebPage.prototype.pushFrame = function(name) {
var frame_no;
if (this["native"]().switchToFrame(name)) {
this.frames.push(name);
return true;
} else {
frame_no = this["native"]().evaluate(function(frame_name) {
Expand All @@ -440,12 +438,7 @@ Poltergeist.WebPage = (function() {
return results;
})())[0];
}, name);
if ((frame_no != null) && this["native"]().switchToFrame(frame_no)) {
this.frames.push(name);
return true;
} else {
return false;
}
return (frame_no != null) && this["native"]().switchToFrame(frame_no);
}
};

Expand All @@ -454,10 +447,8 @@ Poltergeist.WebPage = (function() {
pop_all = false;
}
if (pop_all) {
this.frames = [];
return this["native"]().switchToMainFrame();
} else {
this.frames.pop();
return this["native"]().switchToParentFrame();
}
};
Expand Down
26 changes: 9 additions & 17 deletions lib/capybara/poltergeist/client/web_page.coffee
Expand Up @@ -22,7 +22,6 @@ class Poltergeist.WebPage
@state = 'default'
@urlWhitelist = []
@urlBlacklist = []
@frames = []
@errors = []
@_networkTraffic = {}
@_tempHeaders = {}
Expand Down Expand Up @@ -289,27 +288,20 @@ class Poltergeist.WebPage
this.setCustomHeaders(allHeaders)

pushFrame: (name) ->
if this.native().switchToFrame(name)
@frames.push(name)
return true
else
frame_no = this.native().evaluate(
(frame_name) ->
frames = document.querySelectorAll("iframe, frame")
(idx for f, idx in frames when f?['name'] == frame_name or f?['id'] == frame_name)[0]
, name)
if frame_no? and this.native().switchToFrame(frame_no)
@frames.push(name)
return true
else
return false
return true if this.native().switchToFrame(name)

# if switch by name fails - find index and try again
frame_no = this.native().evaluate(
(frame_name) ->
frames = document.querySelectorAll("iframe, frame")
(idx for f, idx in frames when f?['name'] == frame_name or f?['id'] == frame_name)[0]
, name)
frame_no? and this.native().switchToFrame(frame_no)

popFrame: (pop_all = false)->
if pop_all
@frames = []
this.native().switchToMainFrame()
else
@frames.pop()
this.native().switchToParentFrame()

dimensions: ->
Expand Down

0 comments on commit ae51ce7

Please sign in to comment.