puppeteer/third_party/phantomjs/test/module/webpage/on-initialized.js
Andrey Lushnikov 4372674c99 Improve Phantom_Shim to handle more scenarios. (#49)
This patch improves phantom_shim:
- introduce WebPage.loading/WebPage.loadingProgress
- improve compatibility of WebPage.onInitialized. This allows to
  pass phantomjs tests, even though the implementation is hacky.
- teach PhantomResponse about "stage" state which could be either
  "start" or "end"
- unskip a bunch of phantom webpage tests:
  - webpage/change-request-encoded-url
  - webpage/loading.js
  - webpage/long-running-javascript.js
  - webpage/modify-header.js
  - webpage/on-initialized.js
  - webpage/remove-header.js
2017-07-05 10:07:36 +03:00

22 lines
766 B
JavaScript

test(function () {
var page = require('webpage').create();
assert_equals(page.onInitialized, undefined);
var onInitialized1 = function() { var x = "x"; };
page.onInitialized = onInitialized1;
assert_equals(page.onInitialized, onInitialized1);
var onInitialized2 = function() { var y = "y"; };
page.onInitialized = onInitialized2;
assert_equals(page.onInitialized, onInitialized2);
assert_not_equals(page.onInitialized, onInitialized1);
page.onInitialized = null;
// Will only allow setting to a function value, so setting it to `null` returns `undefined`
assert_equals(page.onInitialized, undefined);
page.onInitialized = undefined;
assert_equals(page.onInitialized, undefined);
}, "page.onInitialized");