Skip to content

Commit

Permalink
Fix multiple document.write calls (#126)
Browse files Browse the repository at this point in the history
  • Loading branch information
weizman authored Jul 17, 2023
1 parent 27c48e3 commit f8bec86
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions test/html.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,39 @@ describe('test HTML injections', async function () {
expect(['V', 'CSP-script-src-elem']).toContain(result);
});

it('should fail to use atob of an iframe introduced via multiple document.write args', async function () {
if (global.BROWSER === 'FIREFOX') {
this.skip(); // requires a fix #58
}
const result = await browser.executeAsync(function(done) {
if (top.TEST_UTILS.bailOnCorrectUnsafeCSP(done)) return;
top.bypass = (wins) => top.TEST_UTILS.bypass(wins, done);
(function(){
var f = document.createElement('iframe');
testdiv.appendChild(f);
f.contentDocument.write('<iframe id="tst');
f.contentDocument.write('"></iframe><script>top.bypass([tst.contentWindow])</script>');
}());
});
expect(['V', 'CSP-script-src-elem']).toContain(result);
});

it('should fail to use atob of an iframe introduced via multiple document.write calls', async function () {
if (global.BROWSER === 'FIREFOX') {
this.skip(); // requires a fix #58
}
const result = await browser.executeAsync(function(done) {
if (top.TEST_UTILS.bailOnCorrectUnsafeCSP(done)) return;
top.bypass = (wins) => top.TEST_UTILS.bypass(wins, done);
(function(){
var f = document.createElement('iframe');
testdiv.appendChild(f);
f.contentDocument.write('<iframe id="tst', '"></iframe><script>top.bypass([tst.contentWindow])</script>');
}());
});
expect(['V', 'CSP-script-src-elem']).toContain(result);
});

it('should fail to use atob of an object through onload as html', async function () {
const result = await browser.executeAsync(function(done) {
top.bypass = (wins) => top.TEST_UTILS.bypass(wins, done);
Expand Down

0 comments on commit f8bec86

Please sign in to comment.