phantomjs - 在客户端代码上设置断点

时间:2014-10-01 08:31:16

标签: javascript debugging phantomjs

我发现this troubleshooting page提到了一种运行调试器的方法,但我似乎无法让它工作。我试图让最基本的例子工作,并且悲惨地失败了。即

runner.js (来自quickstart教程的示例)

var page = require('webpage').create(),
  system = require('system'),
  t, address;

if (system.args.length === 1) {
  console.log('Usage: loadspeed.js <some URL>');
  phantom.exit();
}

t = Date.now();
address = system.args[1];
page.open(address, function(status) {
  if (status !== 'success') {
    console.log('FAIL to load the address');
  } else {
    t = Date.now() - t;
    console.log('Loading time ' + t + ' msec');
  }
  phantom.exit();
});

的test.html

<html>
  <head>
    <title>Script</title>
  </head>
  <body>
    <h1>Script</h1>
  </body>
  <script>
    debugger;
    console.log("hello world;")
  </script>
</html>

然后我跑

$ phantomjs --remote-debugger-autorun=yes --remote-debugger-port=9000 /tmp/runner.js /tmp/test.html
Loading time 6 msec
Phantom::exit() called but not quitting in debug mode.
^C%                                                                                                                                                                    
$ phantomjs --remote-debugger-autorun=yes /tmp/runner.js /tmp/test.html         
Loading time 6 msec
$ phantomjs /tmp/runner.js /tmp/test.html         
Loading time 6 msec

我出错了什么?我期待一个repl或调试接口或其他东西,我误解了文档吗?

编辑:只是澄清localhost:9000并且debugger;声明确实被忽略了 - 即。有“你好世界”;&#39;在控制台

0 个答案:

没有答案