Skip to content
This repository has been archived by the owner on Dec 4, 2019. It is now read-only.

Add support for page#reload #485

Merged
merged 1 commit into from
Jun 15, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export default class Page {
const methods = [
'open', 'render', 'close', 'property', 'injectJs', 'includeJs', 'openUrl', 'stop', 'renderBase64',
'evaluate', 'evaluateJavaScript', 'setting', 'addCookie', 'deleteCookie', 'clearCookies', 'setContent', 'sendEvent',
'switchToMainFrame', 'switchToFrame'
'switchToMainFrame', 'switchToFrame', 'reload'
];

methods.forEach(method => {
Expand Down
15 changes: 15 additions & 0 deletions src/spec/page_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,21 @@ describe('Page', () => {
// confirm we are in the main frame
expect(inMainFrame).toBe(true);
});

it('#reload() will reload the current page', function*() {
let page = yield phantom.createPage();
let reloaded = false;

yield page.open('http://localhost:8888/test');
yield page.on('onNavigationRequested', function(url, type) {
if (type === 'Reload') {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wish there was a better way to test this so that it doesn't rely on a functionality of another method. I don't think there is though.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea, I couldn't think of any other way to verify that the page is actually reloading.

reloaded = true;
}
});
yield page.reload();

expect(reloaded).toBe(true);
});

});