Rename did-navigate-to-different-page to did-navigate
This commit is contained in:
parent
941232a76b
commit
4844e68ba1
6 changed files with 71 additions and 35 deletions
|
@ -566,7 +566,7 @@ void WebContents::DidNavigateMainFrame(
|
||||||
const content::LoadCommittedDetails& details,
|
const content::LoadCommittedDetails& details,
|
||||||
const content::FrameNavigateParams& params) {
|
const content::FrameNavigateParams& params) {
|
||||||
if (details.is_navigation_to_different_page())
|
if (details.is_navigation_to_different_page())
|
||||||
Emit("did-navigate-to-different-page", params.url);
|
Emit("did-navigate", params.url);
|
||||||
else if (details.is_in_page)
|
else if (details.is_in_page)
|
||||||
Emit("did-navigate-in-page", params.url);
|
Emit("did-navigate-in-page", params.url);
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,7 @@ supportedWebViewEvents = [
|
||||||
'devtools-focused'
|
'devtools-focused'
|
||||||
'new-window'
|
'new-window'
|
||||||
'will-navigate'
|
'will-navigate'
|
||||||
'did-navigate-to-different-page'
|
'did-navigate'
|
||||||
'did-navigate-in-page'
|
'did-navigate-in-page'
|
||||||
'close'
|
'close'
|
||||||
'crashed'
|
'crashed'
|
||||||
|
@ -57,7 +57,7 @@ createGuest = (embedder, params) ->
|
||||||
guestInstances[id] = {guest, embedder}
|
guestInstances[id] = {guest, embedder}
|
||||||
|
|
||||||
# Destroy guest when the embedder is gone or navigated.
|
# Destroy guest when the embedder is gone or navigated.
|
||||||
destroyEvents = ['destroyed', 'crashed', 'did-navigate-to-different-page']
|
destroyEvents = ['destroyed', 'crashed', 'did-navigate']
|
||||||
destroy = ->
|
destroy = ->
|
||||||
destroyGuest embedder, id if guestInstances[id]?
|
destroyGuest embedder, id if guestInstances[id]?
|
||||||
for event in destroyEvents
|
for event in destroyEvents
|
||||||
|
|
|
@ -20,7 +20,7 @@ WEB_VIEW_EVENTS =
|
||||||
'devtools-focused': []
|
'devtools-focused': []
|
||||||
'new-window': ['url', 'frameName', 'disposition', 'options']
|
'new-window': ['url', 'frameName', 'disposition', 'options']
|
||||||
'will-navigate': ['url']
|
'will-navigate': ['url']
|
||||||
'did-navigate-to-different-page': ['url']
|
'did-navigate': ['url']
|
||||||
'did-navigate-in-page': ['url']
|
'did-navigate-in-page': ['url']
|
||||||
'close': []
|
'close': []
|
||||||
'crashed': []
|
'crashed': []
|
||||||
|
|
|
@ -129,27 +129,43 @@ Returns:
|
||||||
* `event` Event
|
* `event` Event
|
||||||
* `url` String
|
* `url` String
|
||||||
|
|
||||||
Emitted when a user or the page wants to start navigation. It can happen when the
|
Emitted when a user or the page wants to start navigation. It can happen when
|
||||||
`window.location` object is changed or a user clicks a link in the page.
|
the `window.location` object is changed or a user clicks a link in the page.
|
||||||
|
|
||||||
This event will not emit when the navigation is started programmatically with
|
This event will not emit when the navigation is started programmatically with
|
||||||
APIs like `webContents.loadURL` and `webContents.back`.
|
APIs like `webContents.loadURL` and `webContents.back`.
|
||||||
|
|
||||||
It is also not emitted during in-page navigation, such as clicking anchor links
|
It is also not emitted for in-page navigations, such as clicking anchor links
|
||||||
or updating the `window.location.hash`. Use `did-navigate-in-page` for this purpose.
|
or updating the `window.location.hash`. Use `did-navigate-in-page` event for
|
||||||
|
this purpose.
|
||||||
|
|
||||||
Calling `event.preventDefault()` will prevent the navigation.
|
Calling `event.preventDefault()` will prevent the navigation.
|
||||||
|
|
||||||
### Event: 'did-navigate-to-different-page'
|
### Event: 'did-navigate'
|
||||||
|
|
||||||
Emitted when the new page that was navigated to is different from the previous
|
Returns:
|
||||||
page.
|
|
||||||
|
* `event` Event
|
||||||
|
* `url` String
|
||||||
|
|
||||||
|
Emitted when a navigation is done.
|
||||||
|
|
||||||
|
This event is not emitted for in-page navigations, such as clicking anchor links
|
||||||
|
or updating the `window.location.hash`. Use `did-navigate-in-page` event for
|
||||||
|
this purpose.
|
||||||
|
|
||||||
### Event: 'did-navigate-in-page'
|
### Event: 'did-navigate-in-page'
|
||||||
|
|
||||||
Emitted when the page url changes but does not cause navigation outside of the page.
|
Returns:
|
||||||
Examples of this occurring are when anchor links are clicked or when the
|
|
||||||
DOM `hashchange` event is triggered.
|
* `event` Event
|
||||||
|
* `url` String
|
||||||
|
|
||||||
|
Emitted when an in-page navigation happened.
|
||||||
|
|
||||||
|
When in-page navigation happens, the page URL changes but does not cause
|
||||||
|
navigation outside of the page. Examples of this occurring are when anchor links
|
||||||
|
are clicked or when the DOM `hashchange` event is triggered.
|
||||||
|
|
||||||
### Event: 'crashed'
|
### Event: 'crashed'
|
||||||
|
|
||||||
|
|
|
@ -579,24 +579,44 @@ webview.addEventListener('new-window', function(e) {
|
||||||
### Event: 'will-navigate'
|
### Event: 'will-navigate'
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
|
|
||||||
* `url` String
|
* `url` String
|
||||||
|
|
||||||
Emitted when a user or the page wants to start navigation. It can happen when the
|
Emitted when a user or the page wants to start navigation. It can happen when
|
||||||
`window.location` object is changed or a user clicks a link in the page. It not
|
the `window.location` object is changed or a user clicks a link in the page.
|
||||||
emitted during in-page navigation such as clicking anchor links or updating the
|
|
||||||
`window.location.hash`. Use `did-navigate-in-page` for this purpose.
|
|
||||||
|
|
||||||
|
This event will not emit when the navigation is started programmatically with
|
||||||
|
APIs like `<webview>.loadURL` and `<webview>.back`.
|
||||||
|
|
||||||
### Event: 'did-navigate-to-different-page'
|
It is also not emitted during in-page navigation, such as clicking anchor links
|
||||||
|
or updating the `window.location.hash`. Use `did-navigate-in-page` event for
|
||||||
|
this purpose.
|
||||||
|
|
||||||
Emitted when the new page that was navigated to is different from the previous
|
Calling `event.preventDefault()` does __NOT__ have any effect.
|
||||||
page.
|
|
||||||
|
### Event: 'did-navigate'
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
|
||||||
|
* `url` String
|
||||||
|
|
||||||
|
Emitted when a navigation is done.
|
||||||
|
|
||||||
|
This event is not emitted for in-page navigations, such as clicking anchor links
|
||||||
|
or updating the `window.location.hash`. Use `did-navigate-in-page` event for
|
||||||
|
this purpose.
|
||||||
|
|
||||||
### Event: 'did-navigate-in-page'
|
### Event: 'did-navigate-in-page'
|
||||||
|
|
||||||
Emitted when the page url changes but does not cause navigation outside of the page.
|
Returns:
|
||||||
Examples of this occurring are when anchor links are clicked or when the
|
|
||||||
DOM `hashchange` event is triggered.
|
* `url` String
|
||||||
|
|
||||||
|
Emitted when an in-page navigation happened.
|
||||||
|
|
||||||
|
When in-page navigation happens, the page URL changes but does not cause
|
||||||
|
navigation outside of the page. Examples of this occurring are when anchor links
|
||||||
|
are clicked or when the DOM `hashchange` event is triggered.
|
||||||
|
|
||||||
### Event: 'close'
|
### Event: 'close'
|
||||||
|
|
||||||
|
|
|
@ -280,25 +280,25 @@ describe '<webview> tag', ->
|
||||||
webview.src = "file://#{fixtures}/pages/webview-will-navigate.html"
|
webview.src = "file://#{fixtures}/pages/webview-will-navigate.html"
|
||||||
document.body.appendChild webview
|
document.body.appendChild webview
|
||||||
|
|
||||||
describe 'did-navigate-to-different-page event', ->
|
describe 'did-navigate event', ->
|
||||||
page_url = "file://#{fixtures}/pages/webview-will-navigate.html"
|
pageUrl = "file://#{fixtures}/pages/webview-will-navigate.html"
|
||||||
|
|
||||||
it 'emits when a url that leads to outside of the page is clicked', (done) ->
|
it 'emits when a url that leads to outside of the page is clicked', (done) ->
|
||||||
webview.addEventListener 'did-navigate-to-different-page', (e) ->
|
webview.addEventListener 'did-navigate', (e) ->
|
||||||
assert.equal e.url, page_url
|
assert.equal e.url, pageUrl
|
||||||
done()
|
done()
|
||||||
|
|
||||||
webview.src = page_url
|
webview.src = pageUrl
|
||||||
document.body.appendChild webview
|
document.body.appendChild webview
|
||||||
|
|
||||||
describe 'did-navigate-in-page event', ->
|
describe 'did-navigate-in-page event', ->
|
||||||
it 'emits when an anchor link is clicked', (done) ->
|
it 'emits when an anchor link is clicked', (done) ->
|
||||||
page_url = "file://#{fixtures}/pages/webview-did-navigate-in-page.html"
|
pageUrl = "file://#{fixtures}/pages/webview-did-navigate-in-page.html"
|
||||||
webview.addEventListener 'did-navigate-in-page', (e) ->
|
webview.addEventListener 'did-navigate-in-page', (e) ->
|
||||||
assert.equal e.url, "#{page_url}#test_content"
|
assert.equal e.url, "#{pageUrl}#test_content"
|
||||||
done()
|
done()
|
||||||
|
|
||||||
webview.src = page_url
|
webview.src = pageUrl
|
||||||
document.body.appendChild webview
|
document.body.appendChild webview
|
||||||
|
|
||||||
it 'emits when window.history.replaceState is called', (done) ->
|
it 'emits when window.history.replaceState is called', (done) ->
|
||||||
|
@ -310,12 +310,12 @@ describe '<webview> tag', ->
|
||||||
document.body.appendChild webview
|
document.body.appendChild webview
|
||||||
|
|
||||||
it 'emits when window.location.hash is changed', (done) ->
|
it 'emits when window.location.hash is changed', (done) ->
|
||||||
page_url = "file://#{fixtures}/pages/webview-did-navigate-in-page-with-hash.html"
|
pageUrl = "file://#{fixtures}/pages/webview-did-navigate-in-page-with-hash.html"
|
||||||
webview.addEventListener 'did-navigate-in-page', (e) ->
|
webview.addEventListener 'did-navigate-in-page', (e) ->
|
||||||
assert.equal e.url, "#{page_url}#test"
|
assert.equal e.url, "#{pageUrl}#test"
|
||||||
done()
|
done()
|
||||||
|
|
||||||
webview.src = page_url
|
webview.src = pageUrl
|
||||||
document.body.appendChild webview
|
document.body.appendChild webview
|
||||||
|
|
||||||
describe 'close event', ->
|
describe 'close event', ->
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue