Merge pull request #928 from teampoltergeist/about_blank

current_url should be about:blank when on about:blank - Fix Issue #927
This commit is contained in:
Thomas Walpole 2018-05-22 13:17:44 -07:00 committed by GitHub
commit dd96a31512
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 4 deletions

View File

@ -392,12 +392,12 @@ Poltergeist.WebPage = (function() {
};
WebPage.prototype.currentUrl = function() {
return this["native"]().url;
return this["native"]().url || this.runCommand('frameUrl');
};
WebPage.prototype.frameUrl = function() {
if (phantom.version.major > 2 || (phantom.version.major === 2 && phantom.version.minor >= 1)) {
return this["native"]().frameUrl;
return this["native"]().frameUrl || this.runCommand('frameUrl');
} else {
return this.runCommand('frameUrl');
}

View File

@ -236,11 +236,13 @@ class Poltergeist.WebPage
this.native().frameTitle
currentUrl: ->
@native().url
# native url doesn't return anything when about:blank
# in that case get the frame url which will be main window
@native().url || @runCommand('frameUrl')
frameUrl: ->
if phantom.version.major > 2 || (phantom.version.major == 2 && phantom.version.minor >= 1)
@native().frameUrl
@native().frameUrl || @runCommand('frameUrl')
else
@runCommand('frameUrl')

View File

@ -579,6 +579,11 @@ describe Capybara::Session do
@session.visit "/poltergeist/arbitrary_path/200/foo?a=%20%5B%5D%3A%2F%2B%26%3D"
expect(request_uri).to eq('/poltergeist/arbitrary_path/200/foo?a=%20%5B%5D%3A%2F%2B%26%3D')
end
it 'returns about:blank when on about:blank' do
@session.visit 'about:blank'
expect(@session.current_url).to eq('about:blank')
end
end
context 'dragging support' do