-
Notifications
You must be signed in to change notification settings - Fork 4
/
test.js
38 lines (31 loc) · 871 Bytes
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
var Zone = require("../../lib/zone");
var xhrZone = require("../../xhr");
var testee = require("testee");
var utils = require("./utils");
var mockXHR = utils.mockXHR;
var injectTest = utils.injectTest;
describe("Script injection", function(){
this.timeout(50000);
beforeEach(function(){
var resp = '</script><script>window.FOO=\'bar\';</script>';
this.resetXHR = mockXHR(resp);
});
afterEach(function(){
this.resetXHR();
});
it("Correctly escapes scripts", function(done){
var zone = new Zone({
plugins: [xhrZone]
});
zone.run(function(){
var xhr = new XMLHttpRequest();
xhr.open("GET", "http://example.com");
xhr.send();
}).then(function(data){
injectTest(data.xhr, "test/xss/browser-test");
return testee.test(["test/xss/out.html"], 'firefox', {
reporter: 'Spec'
});
}).then(function() { done(); }, done);
});
});