This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var utils = {}; | |
utils.ab2t = function (buffer) { | |
var arr = new Int8Array(buffer); | |
var str = ""; | |
for(var i = 0, l = arr.length; i < l; i++) { | |
str += String.fromCharCode.call(this, arr[i]); | |
} | |
return str; | |
}; | |
utils.t2ab = function (str) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function (app) { | |
var loading_class = 'loading'; | |
var html = document.documentElement; | |
loading_class = ' ' + loading_class + ' '; | |
//未サポート | |
if (!app || app.UNCACHED === app.status) { | |
init(); | |
return; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function (d,s) {s=d.createElement('script');s.src = 'http://code.jquery.com/jquery-latest.js';d.body.appendChild(s);return s})(document).addEventListener('load', function () {var interval = setInterval(function () { | |
if (!jQuery) { | |
return; | |
} | |
clearInterval(interval); | |
load(); | |
}); | |
}, false); | |
function load () { | |
var sessionId, test_doc; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static function OnBeforeResponse(oSession: Session) | |
{ | |
if (oSession.uriContains('/fiddler.pac')) (function () { | |
var e = new Enumerator(GetObject("winmgmts:{impersonationLevel=impersonate}").ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = True")); | |
var ip = ""; | |
for(; !e.atEnd(); e.moveNext()) { | |
ip = e.item().IPAddress(0); | |
break; | |
} | |
oSession.utilSetResponseBody("function FindProxyForURL(url, host) { return 'PROXY "+ip+":8888'; }"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
body { background-color: #DDDDDD; font: 30px sans-serif; } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
request.responseError = request.offlineError = request.timeoutError = function () { | |
request.callQueue('stop'); | |
alert('Network error\nDo you want to reconnect?'); | |
$('<button id="ok">ok</button><button id="cancel">cancel</button>').appendTo('body') | |
.find('#ok').click(function () { | |
request.callQueue('restart'); | |
}).end() | |
.find('#cancel').click(function () { | |
request.callQueue('abort'); | |
}).end() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<title></title> | |
<script type="text/javascript"> | |
/* | |
// mxhr.js | |
// BSD license | |
var mxhr = new MXHR; | |
mxhr.listen(mime, function(body){ process(body) }); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# SinonJSに登場する各種Objectの解説 | |
1. spy | |
spy methodは渡されたfunctionの動作を生かしつつ、呼び出し時の状態を保持するfunctionへ差し替えます。 | |
spyされたfunctionは呼び出し毎にthis, arguments, return(もしあればthrow)の値がspyCall objectとして保持され、あとからその内容を元にassertを行うことができます。 | |
1. stub |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Jenkinsの「シェルスクリプト」に記述するコマンド例 | |
#--serverで指定しているポート番号は「java -jar JsTestDriver[バージョン番号].jar --port 9876」で指定した内容を記述します。 | |
#--resetは毎回ファイルを読み込み直すため安定した実行が期待できますが、実行時間が長くなるのと、普段(プログラマが行う状態)のテストと状態が異なる可能性があるので、問題が発生した場合は外してみてください。 | |
[javaのパス]java -jar [JsTestDriverのパス]JsTestDriver[バージョン番号].jar --server "http://localhost:9876" --config [テストコードのパス]jstestdriver.conf --tests all --testOutput [適当に空ディレクトリのパス]testOutput/ --reset |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var root = './htdocs/'; | |
var html_path = root + 'index.html'; | |
var output = cwd().file(root + 'js/minified.js').create(); | |
var html = cwd().file(html_path).load('UTF-8'); | |
var target_reg = /<!-- MINIFY_TARGET -->([\s\S]+?)<!-- \/MINIFY_TARGET -->/; | |
var block = html.match(target_reg).pop(); | |
var minify = block.match(/'\/js\/.+?'/g).map(function (path) { | |
return cwd().file(root + path.replace(/'/g, '')).load('UTF-8'); | |
}).join(''); |