Skip to content

Commit

Permalink
major prog
Browse files Browse the repository at this point in the history
  • Loading branch information
weizman committed Jul 10, 2023
1 parent 58748ff commit 858059e
Show file tree
Hide file tree
Showing 23 changed files with 345 additions and 328 deletions.
1 change: 1 addition & 0 deletions chrome.wdio.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ exports.config = {
'goog:chromeOptions': {
args: [
'--headless',
'-auto-open-devtools-for-tabs',
'disable-gpu',
'--enable-features=DocumentPictureInPictureAPI'
],
Expand Down
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'; object-src 'none'; frame-src 'none'; form-action 'self'; frame-ancestors 'none'; navigate-to 'none'">
<meta http-equiv="Content-Security-Policy" content="script-src 'self';">
<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
7 changes: 3 additions & 4 deletions snow.js
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ function makeStringHook(asFrame, asHtml, arg) {
return hook;
}
function dropDeclarativeShadows(shadow, html) {
warn(WARN_DECLARATIVE_SHADOWS, shadow, html);
warn(WARN_DECLARATIVE_SHADOWS, html);
remove(shadow);
return true;
}
Expand Down Expand Up @@ -637,10 +637,9 @@ function warn(msg, a, b) {
let bail;
switch (msg) {
case WARN_DECLARATIVE_SHADOWS:
const shadow = a,
html = b;
const html = a;
bail = false;
console.warn('SNOW:', 'removing html string representing a declarative shadow:', shadow, '\n', `"${html}"`, '.', '\n', 'if this prevents your application from running correctly, please visit/report at', 'https://github.com/LavaMoat/snow/issues/32#issuecomment-1239273328', '.');
console.warn('SNOW:', 'removing html string representing a declarative shadow:', '\n', `"${html}"`, '.', '\n', 'if this prevents your application from running correctly, please visit/report at', 'https://github.com/LavaMoat/snow/issues/32#issuecomment-1239273328', '.');
break;
case WARN_OPEN_API_URL_ARG_JAVASCRIPT_SCHEME:
const url2 = a,
Expand Down
2 changes: 1 addition & 1 deletion snow.prod.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/html.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ function makeStringHook(asFrame, asHtml, arg) {
}

function dropDeclarativeShadows(shadow, html) {
warn(WARN_DECLARATIVE_SHADOWS, shadow, html);
warn(WARN_DECLARATIVE_SHADOWS, html);
remove(shadow);
return true;
}
Expand Down
4 changes: 2 additions & 2 deletions src/log.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ function warn(msg, a, b) {
let bail;
switch (msg) {
case WARN_DECLARATIVE_SHADOWS:
const shadow = a, html = b;
const html = a;
bail = false;
console.warn('SNOW:',
'removing html string representing a declarative shadow:', shadow, '\n', `"${html}"`, '.', '\n',
'removing html string representing a declarative shadow:', '\n', `"${html}"`, '.', '\n',
'if this prevents your application from running correctly, please visit/report at',
'https://github.com/LavaMoat/snow/issues/32#issuecomment-1239273328', '.',
);
Expand Down
24 changes: 12 additions & 12 deletions test/attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,33 +5,33 @@ describe('test DOM attributes', async function () {

it('should fail to use atob of an iframe that calls atob via onload setAttribute', async function () {
const result = await browser.executeAsync(function(done) {
const bypass = (wins) => done(wins.map(win => (win && win.atob ? win : top).atob('WA==')).join(','));
top.bypass = (wins) => top.TEST_UTILS.bypass(wins, done);
(function(){
const ifr = document.createElement('iframe');
ifr.setAttribute('onload', 'top.myatob = this.contentWindow.atob.bind(top);');
testdiv.appendChild(ifr);
bypass([ifr.contentWindow]);
}());
});
expect(result).toBe('V');
expect(['V']).toContain(result);
});

it('should fail to use atob of an iframe that calls atob via onload setAttributeNS', async function () {
const result = await browser.executeAsync(function(done) {
const bypass = (wins) => done(wins.map(win => (win && win.atob ? win : top).atob('WA==')).join(','));
top.bypass = (wins) => top.TEST_UTILS.bypass(wins, done);
(function(){
const ifr = document.createElement('iframe');
ifr.setAttributeNS('', 'onload', 'top.myatob = this.contentWindow.atob.bind(top);');
testdiv.appendChild(ifr);
bypass([ifr.contentWindow]);
}());
});
expect(result).toBe('V');
expect(['V']).toContain(result);
});

it('should fail to use atob of an iframe that calls atob via onload setAttributeNode', async function () {
const result = await browser.executeAsync(function(done) {
const bypass = (wins) => done(wins.map(win => (win && win.atob ? win : top).atob('WA==')).join(','));
top.bypass = (wins) => top.TEST_UTILS.bypass(wins, done);
(function(){
const ifr = document.createElement('iframe');
document.body.setAttributeNS('', 'onload', 'top.myatob = this.contentWindow.atob.bind(top);');
Expand All @@ -40,12 +40,12 @@ describe('test DOM attributes', async function () {
bypass([ifr.contentWindow]);
}());
});
expect(result).toBe('V');
expect(['V']).toContain(result);
});

it('should fail to use atob of an iframe that calls atob via onload setAttributeNodeNS', async function () {
const result = await browser.executeAsync(function(done) {
const bypass = (wins) => done(wins.map(win => (win && win.atob ? win : top).atob('WA==')).join(','));
top.bypass = (wins) => top.TEST_UTILS.bypass(wins, done);
(function(){
const ifr = document.createElement('iframe');
document.body.setAttributeNS('', 'onload', 'top.myatob = this.contentWindow.atob.bind(top);');
Expand All @@ -54,12 +54,12 @@ describe('test DOM attributes', async function () {
bypass([ifr.contentWindow]);
}());
});
expect(result).toBe('V');
expect(['V']).toContain(result);
});

it('should fail to use atob of an iframe that calls atob via onload setNamedItem', async function () {
const result = await browser.executeAsync(function(done) {
const bypass = (wins) => done(wins.map(win => (win && win.atob ? win : top).atob('WA==')).join(','));
top.bypass = (wins) => top.TEST_UTILS.bypass(wins, done);
(function(){
const ifr = document.createElement('iframe');
document.body.setAttributeNS('', 'onload', 'top.myatob = this.contentWindow.atob.bind(top);');
Expand All @@ -68,12 +68,12 @@ describe('test DOM attributes', async function () {
bypass([ifr.contentWindow]);
}());
});
expect(result).toBe('V');
expect(['V']).toContain(result);
});

it('should fail to use atob of an iframe that calls atob via onload setNamedItemNS', async function () {
const result = await browser.executeAsync(function(done) {
const bypass = (wins) => done(wins.map(win => (win && win.atob ? win : top).atob('WA==')).join(','));
top.bypass = (wins) => top.TEST_UTILS.bypass(wins, done);
(function(){
const ifr = document.createElement('iframe');
document.body.setAttributeNS('', 'onload', 'top.myatob = this.contentWindow.atob.bind(top);');
Expand All @@ -82,6 +82,6 @@ describe('test DOM attributes', async function () {
bypass([ifr.contentWindow]);
}());
});
expect(result).toBe('V');
expect(['V']).toContain(result);
});
});
36 changes: 18 additions & 18 deletions test/customs.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ describe('test custom elements', async function () {
this.skip(); // extending iframes is not supported in Safari
}
const result = await browser.executeAsync(function(done) {
const bypass = (wins) => done(wins.map(win => (win && win.atob ? win : top).atob('WA==')).join(','));
top.bypass = (wins) => top.TEST_UTILS.bypass(wins, done);
(function(){
setTimeout(bypass, 100, [window]);

Expand All @@ -32,15 +32,15 @@ describe('test custom elements', async function () {
testdiv.appendChild(ifr);
}());
});
expect(result).toBe('V');
expect(['V']).toContain(result);
});

it('should fail to use atob of an iframe that is loaded via a custom element with connectedCallback (with src)', async function () {
if (global.BROWSER === 'SAFARI') {
this.skip(); // extending iframes is not supported in Safari
}
const result = await browser.executeAsync(function(done) {
const bypass = (wins) => done(wins.map(win => (win && win.atob ? win : top).atob('WA==')).join(','));
top.bypass = (wins) => top.TEST_UTILS.bypass(wins, done);
(function(){
setTimeout(bypass, 100, [window]);

Expand All @@ -63,15 +63,15 @@ describe('test custom elements', async function () {
testdiv.appendChild(ifr);
}());
});
expect(result).toBe('V');
expect(['V']).toContain(result);
});

it('should fail to use atob of an frame that is loaded via a custom element with connectedCallback', async function () {
if (global.BROWSER === 'SAFARI') {
this.skip(); // extending iframes is not supported in Safari
}
const result = await browser.executeAsync(function(done) {
const bypass = (wins) => done(wins.map(win => (win && win.atob ? win : top).atob('WA==')).join(','));
top.bypass = (wins) => top.TEST_UTILS.bypass(wins, done);
(function(){
setTimeout(bypass, 100, [window]);

Expand All @@ -96,15 +96,15 @@ describe('test custom elements', async function () {
testdiv.appendChild(set);
}());
});
expect(result).toBe('V');
expect(['V']).toContain(result);
});

it('should fail to use atob of an object that is loaded via a custom element with connectedCallback', async function () {
if (global.BROWSER === 'SAFARI') {
this.skip(); // extending iframes is not supported in Safari
}
const result = await browser.executeAsync(function(done) {
const bypass = (wins) => done(wins.map(win => (win && win.atob ? win : top).atob('WA==')).join(','));
top.bypass = (wins) => top.TEST_UTILS.bypass(wins, done);
(function(){
setTimeout(bypass, 100, [window]);

Expand All @@ -127,15 +127,15 @@ describe('test custom elements', async function () {
testdiv.appendChild(object);
}());
});
expect(result).toBe('V');
expect(['V']).toContain(result);
});

it('should fail to use atob of an embed that is loaded via a custom element with connectedCallback', async function () {
if (global.BROWSER === 'SAFARI') {
this.skip(); // extending iframes is not supported in Safari
}
const result = await browser.executeAsync(function(done) {
const bypass = (wins) => done(wins.map(win => (win && win.atob ? win : top).atob('WA==')).join(','));
top.bypass = (wins) => top.TEST_UTILS.bypass(wins, done);
(function(){
setTimeout(bypass, 100, [window]);

Expand All @@ -158,15 +158,15 @@ describe('test custom elements', async function () {
testdiv.appendChild(embed);
}());
});
expect(result).toBe('V');
expect(['V']).toContain(result);
});

it('should fail to use atob of an iframe that is loaded via a custom element with connectedCallback through html', async function () {
if (global.BROWSER === 'SAFARI') {
this.skip(); // extending iframes is not supported in Safari
}
const result = await browser.executeAsync(function(done) {
const bypass = (wins) => done(wins.map(win => (win && win.atob ? win : top).atob('WA==')).join(','));
top.bypass = (wins) => top.TEST_UTILS.bypass(wins, done);
(function(){
setTimeout(bypass, 100, [window]);

Expand All @@ -187,15 +187,15 @@ describe('test custom elements', async function () {
testdiv.innerHTML = `<iframe is="legit-element${n}"></iframe>`;
}());
});
expect(result).toBe('V');
expect(['V']).toContain(result);
});

it('should fail to use atob of an iframe that is loaded via a custom element with attributeChangedCallback', async function () {
if (global.BROWSER === 'SAFARI') {
this.skip(); // extending iframes is not supported in Safari
}
const result = await browser.executeAsync(function(done) {
const bypass = (wins) => done(wins.map(win => (win && win.atob ? win : top).atob('WA==')).join(','));
top.bypass = (wins) => top.TEST_UTILS.bypass(wins, done);
(function(){
setTimeout(bypass, 100, [window]);

Expand All @@ -222,15 +222,15 @@ describe('test custom elements', async function () {
setTimeout(() => ifr.setAttribute('src', '/'), 100);
}());
});
expect(result).toBe('V');
expect(['V']).toContain(result);
});

it('should fail to use atob of an iframe that is loaded via a custom element with adoptedCallback', async function () {
if (global.BROWSER === 'SAFARI') {
this.skip(); // extending iframes is not supported in Safari
}
const result = await browser.executeAsync(function(done) {
const bypass = (wins) => done(wins.map(win => (win && win.atob ? win : top).atob('WA==')).join(','));
top.bypass = (wins) => top.TEST_UTILS.bypass(wins, done);
(function(){
setTimeout(bypass, 100, [window]);

Expand All @@ -255,15 +255,15 @@ describe('test custom elements', async function () {
setTimeout(() => ifr2.contentDocument.body.appendChild(ifr), 100);
}());
});
expect(result).toBe('V');
expect(['V']).toContain(result);
});

it('should fail to use atob of an iframe that is loaded via a custom element with adoptedCallback through html', async function () {
if (global.BROWSER === 'SAFARI') {
this.skip(); // extending iframes is not supported in Safari
}
const result = await browser.executeAsync(function(done) {
const bypass = (wins) => done(wins.map(win => (win && win.atob ? win : top).atob('WA==')).join(','));
top.bypass = (wins) => top.TEST_UTILS.bypass(wins, done);
(function(){
setTimeout(bypass, 100, [window]);

Expand All @@ -287,6 +287,6 @@ describe('test custom elements', async function () {
setTimeout(() => ifr2.contentDocument.body.appendChild(xxx), 100);
}());
});
expect(result).toBe('V');
expect(['V']).toContain(result);
});
});
Loading

0 comments on commit 858059e

Please sign in to comment.