Skip to content
This repository has been archived by the owner on May 30, 2023. It is now read-only.

Javascript loading error in simple phantomjs script #14317

Closed
blackmad opened this issue May 26, 2016 · 2 comments
Closed

Javascript loading error in simple phantomjs script #14317

blackmad opened this issue May 26, 2016 · 2 comments

Comments

@blackmad
Copy link

  1. Which version of PhantomJS are you using? Tip: run phantomjs --version.
    2.1.1
  2. What steps will reproduce the problem?
    screenshot.js:
    var page = require('webpage').create();
    var url = 'http://blackmad.github.io/stellabot/web/jaspers_dilemma.html';
    page.open(url, function() {
    page.render('github.png');
    phantom.exit();
    })

output:
[dblackman@tw-mbp-dblackman py_screenshot_server (master)]$ phantomjs screenshot.js
ReferenceError: Can't find variable: draw_everything

http://blackmad.github.io/stellabot/web/common.js:25 in resize_canvas
http://blackmad.github.io/stellabot/web/common.js:49
http://blackmad.github.io/stellabot/web/third_party/jquery.min.js:2 in i
http://blackmad.github.io/stellabot/web/third_party/jquery.min.js:2 in fireWith
http://blackmad.github.io/stellabot/web/third_party/jquery.min.js:2 in ready
http://blackmad.github.io/stellabot/web/third_party/jquery.min.js:2 in J
ReferenceError: Can't find variable: draw_everything

http://blackmad.github.io/stellabot/web/common.js:25 in resize_canvas
http://blackmad.github.io/stellabot/web/third_party/jquery.min.js:3 in dispatch
http://blackmad.github.io/stellabot/web/third_party/jquery.min.js:3 in handle
:0 in render
phantomjs://code/screenshot.js:4
phantomjs://platform/webpage.js:286 in _onPageOpenFinished
ReferenceError: Can't find variable: draw_everything

http://blackmad.github.io/stellabot/web/common.js:25 in resize_canvas
http://blackmad.github.io/stellabot/web/third_party/jquery.min.js:3 in dispatch
http://blackmad.github.io/stellabot/web/third_party/jquery.min.js:3 in handle
:0 in render
phantomjs://code/screenshot.js:4
phantomjs://platform/webpage.js:286 in _onPageOpenFinished

  1. Which operating system are you using? OS X
  2. Did you use binary PhantomJS or did you compile it from source? source
  3. Please provide any additional information below.
    The page loads fine in chrome. I've tried making it more valid html (Didn't help) and changing from document.ready to window.load, didn't help either.

draw_everything is defined in jaspers_dilemma.js, I don't know why it's not getting loaded

@veltman
Copy link

veltman commented May 26, 2016

I think the problem is this ES6-y default arg syntax:

function draw_everything({
  canvas = this.canvas,
  alwaysGlitch = this.alwaysGlitch
}){

if you replace with:

function drawEverything(params) {
  var canvas = params.canvas,
      alwaysGlitch = params.alwaysGlitch;

it seems to work.

@ariya
Copy link
Owner

ariya commented Aug 25, 2016

Please track ES6 support in #14506. Thank you!

@ariya ariya closed this as completed Aug 25, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants