捕捉浏览器中的JS运行时错误,主要通过监听window.onerror来实现。但是对于不同的脚本执行方式以及不同的浏览器,能捕获到的信息会有区别。
window.onerror 讲接收3个参数:
msg:错误描述,比如:a is not definedurl:出错脚本所在的urllineNumber:出错脚本的行数
本文将对不同浏览器和不同的脚本执行方式进行测试,并总结这些区别。
| var child_process = require('child_process'); | |
| // exec: spawns a shell. | |
| child_process.exec('ls -lah /tmp', function(error, stdout, stderr){ | |
| console.log(stdout); | |
| }); | |
| // execFile: executes a file with the specified arguments | |
| child_process.execFile('ls', ['-lah', '/tmp'], function(error, stdout, stderr){ | |
| console.log(stdout); |
| //app.js Socket IO Test | |
| var app = require('express').createServer(), | |
| redis = require('socket.io/node_modules/redis'), | |
| io = require('socket.io').listen(app); | |
| var pub = redis.createClient(port, "url"); | |
| var sub = redis.createClient(port, "url"); | |
| var store = redis.createClient(port, "url"); | |
| pub.auth('pass', function(){console.log("adentro! pub")}); | |
| sub.auth('pass', function(){console.log("adentro! sub")}); |
捕捉浏览器中的JS运行时错误,主要通过监听window.onerror来实现。但是对于不同的脚本执行方式以及不同的浏览器,能捕获到的信息会有区别。
window.onerror 讲接收3个参数:
msg:错误描述,比如:a is not definedurl:出错脚本所在的urllineNumber:出错脚本的行数本文将对不同浏览器和不同的脚本执行方式进行测试,并总结这些区别。
Eric Bidelman has documented some of the common workflows possible with headless Chrome over in https://developers.google.com/web/updates/2017/04/headless-chrome.
If you're looking at this in 2016 and beyond, I strongly recommend investigating real headless Chrome: https://chromium.googlesource.com/chromium/src/+/lkgr/headless/README.md
Windows and Mac users might find using Justin Ribeiro's Docker setup useful here while full support for these platforms is being worked out.
| # 1. Make sure you have nginx sub module compiled in | |
| # nginx -V 2>&1 | grep --color=always '\-\-with\-http_sub_module' | |
| # 2. add two directives below at HTTP level | |
| # nginx.conf | |
| http { | |
| # ...... | |
| sub_filter '</head>' '<style type="text/css">html{ filter: progid:DXImageTransform.Microsoft.BasicImage(grayscale=1); -webkit-filter: grayscale(100%); filter: url("data:image/svg+xml;utf8,<svg xmlns=\'http://www.w3.org/2000/svg\'><filter id=\'grayscale\'><feColorMatrix type=\'matrix\' values=\'0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0 0 0 1 0\'/></filter></svg>#grayscale"); /* Firefox 10+, Firefox on Android */ |
| var React = require('react'); | |
| var EventListener = require('react/lib/EventListener'); | |
| var partition = require('linear-partitioning'); | |
| var TileLayout = React.createClass({ | |
| getDefaultProps: function() { | |
| return { | |
| gutter: 0, | |
| photos: [] | |
| } |
| import { combineReducers } from 'redux'; | |
| import users from './reducers/users'; | |
| import posts from './reducers/posts'; | |
| export default function createReducer(asyncReducers) { | |
| return combineReducers({ | |
| users, | |
| posts, | |
| ...asyncReducers | |
| }); |
| var factors = [7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2] | |
| var tails = ['1', '0', 'X', '9', '8', '7', '6', '5', '4', '3', '2'] | |
| var provinceMap = { | |
| 11: '北京', | |
| 12: '天津', | |
| 13: '河北', | |
| 14: '山西', | |
| 15: '内蒙古', | |
| 21: '辽宁', | |
| 22: '吉林', |
Pre-reqs: