[关闭]
@bornkiller 2015-03-10T03:05:51.000000Z 字数 2949 阅读 2370

查缺补漏


javascript


Youku Lights Off

  1. (function(){
  2. document.querySelector('#vpofficialtitlev5_wrap').style.display = 'none';
  3. document.querySelector('#qheader').style.display = 'none';
  4. document.querySelector('#vpofficialinfov5_wrap').style.display = 'none';
  5. box = document.querySelectorAll('.box')
  6. for (var i=0; i<box.length; i++) {box[i].style.display = 'none';}
  7. document.querySelector('#qfooter').style.display = 'none';
  8. document.querySelector('.mainCol').style.display = 'none';
  9. document.querySelector('#sideTool').style.display = 'none';
  10. document.body.style.backgroundColor='black';
  11. document.querySelector('.screen').style.marginTop='80px';
  12. })()

Web Worker

superagent 在worker中使用,调整line 205:

  1. var root = 'undefined' == typeof window
  2. ? self
  3. : window;

Koa 中间件列表

nginx配置

gzip

关于非运算符

  1. if (!obj.constructor || !(Object == obj.constructor)) return '';
  2. if (!obj.constructor || !Object == obj.constructor) return '';

关于input placeholder

placeholder

关于webdriver-manager

依赖文件路径

  1. jasonborndeMacBook-Air:selenium jasonborn$ ls
  2. chromedriver_2.12.zip
  3. selenium-server-standalone-2.44.0.jar
  4. jasonborndeMacBook-Air:selenium jasonborn$ pwd
  5. /usr/local/lib/node_modules/protractor/selenium

配置文件

  1. // An example configuration file
  2. exports.config = {
  3. // The address of a running selenium server.
  4. seleniumAddress: 'http://localhost:4444/wd/hub',
  5. // Capabilities to be passed to the webdriver instance.
  6. capabilities: {
  7. 'browserName': 'chrome'
  8. },
  9. // Spec patterns are relative to the configuration file location passed
  10. // to protractor (in this example conf.js).
  11. // They may include glob patterns.
  12. specs: ['index.spec.js'],
  13. directConnect: true,
  14. // Options to be passed to Jasmine-node.
  15. jasmineNodeOpts: {
  16. showColors: true // Use colors in the command line report.
  17. }
  18. };

测试文件

  1. // spec.js
  2. describe('snowykiss homepage', function() {
  3. it('should have a title', function() {
  4. browser.get('http://127.0.0.1:1336/');
  5. expect(browser.getTitle()).toEqual('web worker');
  6. });
  7. });

待测试页面必须为完整的angular application,否则会报错。

文件下载

  1. download = document.createElement("A");
  2. download.href = url;
  3. document.body.appendChild(download);
  4. download.click();
  5. setTimeout(function() { download.parentNode.removeChild(download); }, 50);

DEBUG模块使用

  1. var debug = require('debug')('master');
  2. var deviant = require('debug')('master');
  3. // 调整信息输出方法
  4. deviant.log = console.error.bind(console);
  5. deviant('place error default standard output');
  6. // 用以计时亦可
  7. debug('the %s has never change', 'world');
  8. setTimeout(function() {
  9. debug('the %s has never change', 'human');
  10. }, 200);
  1. # 不清楚具体原理,必须置于最前
  2. DEBUG=* node slavery.js

PHANTOMJS_BIN

OSX下使用karma调用headless浏览器时,需要声明

  1. declare -x PHANTOM_JS='/usr/local/bin/phantomjs';

Jasmine

  1. getJasmineRequireObj().toBeCloseTo = function() {
  2. function toBeCloseTo() {
  3. return {
  4. compare: function(actual, expected, precision) {
  5. if (precision !== 0) {
  6. precision = precision || 2;
  7. }
  8. return {
  9. pass: Math.abs(expected - actual) < (Math.pow(10, -precision) / 2)
  10. };
  11. }
  12. };
  13. }
  14. return toBeCloseTo;
  15. };

angular测试中触发ng-model更新

  1. // version-1
  2. element.val('colorful');
  3. element.trigger($sniffer.hasEvent('input') ? 'input' : 'change');
  4. // version-2
  5. ngModelController = el.find('input').controller('ngModel');
  6. ngModelController.$setViewValue('test');
添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注