request-credentials.window.js (1413B)
1 // META: title=EventSource: credentials 2 var crossdomain = location.href 3 .replace('://', '://www2.') 4 .replace(/\/[^\/]*$/, '/') 5 6 function testCookie(desc, success, props, id) { 7 var test = async_test(document.title + ': credentials ' + desc) 8 test.step(function() { 9 var source = new EventSource(crossdomain + "resources/cors-cookie.py?ident=" + id, props) 10 11 source.onmessage = test.step_func(function(e) { 12 if(e.data.indexOf("first") == 0) { 13 assert_equals(e.data, "first NO_COOKIE", "cookie status") 14 } 15 else if(e.data.indexOf("second") == 0) { 16 if (success) 17 assert_equals(e.data, "second COOKIE", "cookie status") 18 else 19 assert_equals(e.data, "second NO_COOKIE", "cookie status") 20 21 source.close() 22 test.done() 23 } 24 else { 25 assert_unreached("unrecognized data returned: " + e.data) 26 source.close() 27 test.done() 28 } 29 }) 30 }) 31 } 32 33 testCookie('enabled', true, { withCredentials: true }, '1_' + new Date().getTime()) 34 testCookie('disabled', false, { withCredentials: false }, '2_' + new Date().getTime()) 35 testCookie('default', false, { }, '3_' + new Date().getTime())