Skip to content

Commit

Permalink
add support for object-src block
Browse files Browse the repository at this point in the history
  • Loading branch information
weizman committed Jul 11, 2023
1 parent 60dfa89 commit 20aae8b
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 7 deletions.
2 changes: 1 addition & 1 deletion demo/index.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<html>
<head>
<meta http-equiv="Content-Security-Policy" content="script-src 'self';">
<meta http-equiv="Content-Security-Policy" content="script-src 'self'; object-src 'none';">
<link rel="icon" href="data:image/svg+xml,<svg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 100 100%22><text y=%22.9em%22 font-size=%2290%22>❄️</text></svg>">
<title> Snow </title>
<script src="../snow.js"></script>
Expand Down
5 changes: 4 additions & 1 deletion firefox.wdio.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,10 @@ exports.config = {
//
browserName: 'firefox',
'moz:firefoxOptions': {
args: ['--headless', 'disable-gpu'],
args: [
'--headless',
'disable-gpu',
],
},
acceptInsecureCerts: true
// If outputDir is provided WebdriverIO can capture driver session logs
Expand Down
11 changes: 6 additions & 5 deletions test/index.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
const fs = require('fs');
const path = require('path');

const csp = `script-src 'self';`;
const CSP = `script-src 'self'; object-src 'none';`;
const URL = 'https://weizman.github.io/CSPer/';

const snow = fs.readFileSync(path.join(__dirname, '../snow.prod.js')).toString();

function getURL() {
let url = 'https://weizman.github.io/CSPer/';
let url = URL;
if (global.BROWSER === 'CHROME') {
url += '?csp=' + csp;
url += '?csp=' + CSP;
}
return url;
}
Expand Down Expand Up @@ -45,14 +46,14 @@ async function setupChrome() {
await browser.call(async () => {
const pages = await puppeteerBrowser.pages();
const page = pages[0];
await page.evaluateOnNewDocument(setTestUtils, csp);
await page.evaluateOnNewDocument(setTestUtils, CSP);
})
}

async function setup(url = getURL(), noSnow) {
await browser.url(url);

await browser.execute(setTestUtils, csp);
await browser.execute(setTestUtils, CSP);

if (noSnow) return;

Expand Down
3 changes: 3 additions & 0 deletions test/views.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ describe('test different views', async function () {
});

it('should fail to use atob of an object', async function () {
if (global.BROWSER === 'FIREFOX') {
this.skip(); // requires a fix #59
}
const result = await browser.executeAsync(function(done) {
top.bypass = (wins) => top.TEST_UTILS.bypass(wins, done);
(function(){
Expand Down

0 comments on commit 20aae8b

Please sign in to comment.