WebPage.onInitialized is not called when set #47
Description
Bug
Setting the onInitialized function does not cause it to be called, as the check to call it is currently in the WebPage constructor (init function of WebPage.js).
Steps to Reproduce
run:
TrifleJS.exe onInitialized.js
onInitialized.js:
var page = webpage = require('webpage').create();
page.onInitialized = function() {
console.log('should log');
};
// any url
page.open('about:blank');
Expected Output (PhantomJS)
should log
Actual Output (TrifleJS)
The PhantomJS spec says (http://phantomjs.org/api/webpage/handler/on-initialized.html):
This callback is invoked after the web page is created but before a URL is loaded. The callback may be used to change global objects.
The logic should be moved into the open function. This is actually a bit trickier than it looks at first glance because the PhantomJS spec allows you to change global objects on the page, which the .NET client will clear on calls to navigate. A callback needs to be set up to invoke the supplied function at the proper time after creating the page.