| OLD | NEW |
| 1 (function() | 1 (function() |
| 2 { | 2 { |
| 3 let server = null; | 3 let server = null; |
| 4 let frame = null; | 4 let frame = null; |
| 5 let requestNotifier = null; | 5 let requestNotifier = null; |
| 6 let httpProtocol = null; | 6 let httpProtocol = null; |
| 7 | 7 |
| 8 module("Content policy", { | 8 module("Content policy", { |
| 9 setup: function() | 9 setup: function() |
| 10 { | 10 { |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 -----END RSA PRIVATE KEY----- | 58 -----END RSA PRIVATE KEY----- |
| 59 */ | 59 */ |
| 60 let publickey = "MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBALZc50pEXnz9TSRozwM04rryuaXl/
wgUFqV9FHq8HDlkdKvRU0hXhb/AKrSpCJ0NCxHtal1l/kHYlHG9e7Ev6+MCAwEAAQ"; | 60 let publickey = "MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBALZc50pEXnz9TSRozwM04rryuaXl/
wgUFqV9FHq8HDlkdKvRU0hXhb/AKrSpCJ0NCxHtal1l/kHYlHG9e7Ev6+MCAwEAAQ"; |
| 61 | 61 |
| 62 /** | 62 /** |
| 63 * Content: | 63 * Content: |
| 64 * /test\0127.0.0.1:1234\0Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:30.0) Gec
ko/20100101 Firefox/30.0 | 64 * /test\0127.0.0.1:1234\0Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:30.0) Gec
ko/20100101 Firefox/30.0 |
| 65 */ | 65 */ |
| 66 let adblockkey = "MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBALZc50pEXnz9TSRozwM04rryuaXl
/wgUFqV9FHq8HDlkdKvRU0hXhb/AKrSpCJ0NCxHtal1l/kHYlHG9e7Ev6+MCAwEAAQ==_gM4C/j8KkD2
byPeP+THXk1GbLTUm5y+5jbdhcMtnzPMgImIfge0dGCtfU9cxLpe8BnqnEGNhTxpuu4pZxjOHYQ=="; | 66 let adblockkey = "MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBALZc50pEXnz9TSRozwM04rryuaXl
/wgUFqV9FHq8HDlkdKvRU0hXhb/AKrSpCJ0NCxHtal1l/kHYlHG9e7Ev6+MCAwEAAQ==_gM4C/j8KkD2
byPeP+THXk1GbLTUm5y+5jbdhcMtnzPMgImIfge0dGCtfU9cxLpe8BnqnEGNhTxpuu4pZxjOHYQ=="; |
| 67 | 67 |
| 68 let dispatchReadyEvent = "document.dispatchEvent(new CustomEvent('abp:framerea
dy', {bubbles: true}));"; |
| 69 |
| 68 let tests = [ | 70 let tests = [ |
| 69 [ | 71 [ |
| 70 "HTML image with relative URL", | 72 "HTML image with relative URL", |
| 71 '<img src="test.gif">', | 73 '<img src="test.gif">', |
| 72 "http://127.0.0.1:1234/test.gif", "image", false, false | 74 "http://127.0.0.1:1234/test.gif", "image", false, false |
| 73 ], | 75 ], |
| 74 [ | 76 [ |
| 75 "HTML image with absolute URL", | 77 "HTML image with absolute URL", |
| 76 '<img src="http://localhost:1234/test.gif">', | 78 '<img src="http://localhost:1234/test.gif">', |
| 77 "http://localhost:1234/test.gif", "image", true, false | 79 "http://localhost:1234/test.gif", "image", true, false |
| (...skipping 17 matching lines...) Expand all Loading... |
| 95 "Dynamically inserted image button", | 97 "Dynamically inserted image button", |
| 96 '<div id="insert"></div>' + | 98 '<div id="insert"></div>' + |
| 97 '<script>' + | 99 '<script>' + |
| 98 'window.addEventListener("DOMContentLoaded", function()' + | 100 'window.addEventListener("DOMContentLoaded", function()' + |
| 99 '{' + | 101 '{' + |
| 100 'var div = document.getElementById("insert");' + | 102 'var div = document.getElementById("insert");' + |
| 101 'div.innerHTML = \'<input type="image" id="image" src="test.gif">\';'
+ | 103 'div.innerHTML = \'<input type="image" id="image" src="test.gif">\';'
+ |
| 102 'var image = document.getElementById("image");' + | 104 'var image = document.getElementById("image");' + |
| 103 'image.onload = image.onerror = function ()' + | 105 'image.onload = image.onerror = function ()' + |
| 104 '{' + | 106 '{' + |
| 105 'document.dispatchEvent(new CustomEvent("abp:frameready", {bubbles:
true}));' + | 107 dispatchReadyEvent + |
| 106 '};' + | 108 '};' + |
| 107 '}, false);' + | 109 '}, false);' + |
| 108 '</script>', | 110 '</script>', |
| 109 "http://127.0.0.1:1234/test.gif", "image", false, true | 111 "http://127.0.0.1:1234/test.gif", "image", false, true |
| 110 ], | 112 ], |
| 111 [ | 113 [ |
| 112 "CSS background-image", | 114 "CSS background-image", |
| 113 '<div style="background-image: url(test.gif)"></div>', | 115 '<div style="background-image: url(test.gif)"></div>', |
| 114 "http://127.0.0.1:1234/test.gif", "image", false, false | 116 "http://127.0.0.1:1234/test.gif", "image", false, false |
| 115 ], | 117 ], |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 'xmlDoc.async = false;' + | 212 'xmlDoc.async = false;' + |
| 211 'xmlDoc.load("test.xml");' + | 213 'xmlDoc.load("test.xml");' + |
| 212 '}' + | 214 '}' + |
| 213 'catch(e){}' + | 215 'catch(e){}' + |
| 214 '</script>', | 216 '</script>', |
| 215 "http://127.0.0.1:1234/test.xml", "xmlhttprequest", false, false | 217 "http://127.0.0.1:1234/test.xml", "xmlhttprequest", false, false |
| 216 ], | 218 ], |
| 217 [ | 219 [ |
| 218 "Web worker", | 220 "Web worker", |
| 219 '<script>' + | 221 '<script>' + |
| 220 'var e = new CustomEvent(\'abp:frameready\', {bubbles: true});' + | |
| 221 'try' + | 222 'try' + |
| 222 '{' + | 223 '{' + |
| 223 'var worker = new Worker("test.js");' + | 224 'var worker = new Worker("test.js");' + |
| 224 'worker.onerror = function(event)' + | 225 'worker.onerror = function(event)' + |
| 225 '{' + | 226 '{' + |
| 226 'event.preventDefault();' + | 227 'event.preventDefault();' + |
| 227 'document.dispatchEvent(e);' + | 228 dispatchReadyEvent + |
| 228 '};' + | 229 '};' + |
| 229 '}' + | 230 '}' + |
| 230 'catch (x)' + | 231 'catch (e)' + |
| 231 '{' + | 232 '{' + |
| 232 'document.dispatchEvent(e);' + | 233 dispatchReadyEvent + |
| 233 '}' + | 234 '}' + |
| 234 '</script>', | 235 '</script>', |
| 235 "http://127.0.0.1:1234/test.js", "script", false, true | 236 "http://127.0.0.1:1234/test.js", "script", false, true |
| 236 ], | 237 ], |
| 237 ]; | 238 ]; |
| 238 | 239 |
| 239 if (window.navigator.mimeTypes["application/x-shockwave-flash"] && window.navi
gator.mimeTypes["application/x-shockwave-flash"].enabledPlugin) | 240 if (window.navigator.mimeTypes["application/x-shockwave-flash"] && window.navi
gator.mimeTypes["application/x-shockwave-flash"].enabledPlugin) |
| 240 { | 241 { |
| 241 tests.push([ | 242 tests.push([ |
| 242 "HTML embed (Flash)", | 243 "HTML embed (Flash)", |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 302 defaultMatcher.add(Filter.fromText("@@||127.0.0.1:1234/test|$document")); | 303 defaultMatcher.add(Filter.fromText("@@||127.0.0.1:1234/test|$document")); |
| 303 if (stage == 4) | 304 if (stage == 4) |
| 304 defaultMatcher.add(Filter.fromText("@@||127.0.0.1:1234/test|$~document")); | 305 defaultMatcher.add(Filter.fromText("@@||127.0.0.1:1234/test|$~document")); |
| 305 if (stage == 5) | 306 if (stage == 5) |
| 306 defaultMatcher.add(Filter.fromText("@@||127.0.0.1:1234/test|$document,site
key=" + publickey)); | 307 defaultMatcher.add(Filter.fromText("@@||127.0.0.1:1234/test|$document,site
key=" + publickey)); |
| 307 | 308 |
| 308 if (!explicitEvent) | 309 if (!explicitEvent) |
| 309 { | 310 { |
| 310 if (body.indexOf("2000/svg") >= 0) | 311 if (body.indexOf("2000/svg") >= 0) |
| 311 { | 312 { |
| 312 // SVG image: add an onload attribute to the document element | 313 // SVG image: add an onload attribute to the document element and keep |
| 313 body = body.replace(/(<svg\b)/, '$1 onload="this.dispatchEvent(new Custo
mEvent(\'abp:frameready\', {bubbles: true}));"'); | 314 // polling until the document is really loaded. |
| 315 body = body.replace(/(<svg\b)/, '$1 onload="if (document.readyState != \
'complete\') setTimeout(arguments.callee.bind(this), 0); else ' + dispatchReadyE
vent + '"'); |
| 314 } | 316 } |
| 315 else | 317 else |
| 316 { | 318 { |
| 317 // HTML data: wrap it into a <body> tag | 319 // HTML data: wrap it into a <body> tag |
| 318 body = '<body onload="this.dispatchEvent(new CustomEvent(\'abp:frameread
y\', {bubbles: true}));">' + body + '</body>'; | 320 body = '<body onload="' + dispatchReadyEvent + '">' + body + '</body>'; |
| 319 } | 321 } |
| 320 } | 322 } |
| 321 | 323 |
| 322 let serverHit = false; | 324 let serverHit = false; |
| 323 server.registerPathHandler("/test", function(metadata, response) | 325 server.registerPathHandler("/test", function(metadata, response) |
| 324 { | 326 { |
| 325 response.setStatusLine("1.1", "200", "OK"); | 327 response.setStatusLine("1.1", "200", "OK"); |
| 326 | 328 |
| 327 let contentType = "text/html"; | 329 let contentType = "text/html"; |
| 328 if (body.indexOf("2000/svg") >= 0) | 330 if (body.indexOf("2000/svg") >= 0) |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 408 for (let stage = 1; stage in stageDescriptions; stage++) | 410 for (let stage = 1; stage in stageDescriptions; stage++) |
| 409 { | 411 { |
| 410 let stageDescription = stageDescriptions[stage]; | 412 let stageDescription = stageDescriptions[stage]; |
| 411 if (stageDescription.indexOf("%S") >= 0) | 413 if (stageDescription.indexOf("%S") >= 0) |
| 412 stageDescription = stageDescription.replace("%S", expectedURL); | 414 stageDescription = stageDescription.replace("%S", expectedURL); |
| 413 | 415 |
| 414 asyncTest(name + " (" + stageDescription + ")", runTest.bind(null, tests[t
est], stage)); | 416 asyncTest(name + " (" + stageDescription + ")", runTest.bind(null, tests[t
est], stage)); |
| 415 } | 417 } |
| 416 } | 418 } |
| 417 })(); | 419 })(); |
| OLD | NEW |