Skip to content

Commit

Permalink
Bypass state partitioning by showing report in iframe
Browse files Browse the repository at this point in the history
  • Loading branch information
ausi committed Aug 4, 2023
1 parent f2008cb commit 194f755
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 4 deletions.
30 changes: 26 additions & 4 deletions src/collector.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import 'whatwg-fetch';
import collector from './collector/index';
import setStyles from './util/setStyles';

const script = document.getElementById('respimagelint-script');
const scriptBase = script ? script.src.split('?')[0].replace(/[^/]+$/, '') : 'https://ausi.github.io/respimagelint/';
let iframe;

collector(document).then(data => {

Expand All @@ -19,14 +21,34 @@ collector(document).then(data => {
}
});

let store = document.createElement('iframe');
store.src = scriptBase + 'store.html';
document.body.appendChild(store);
setStyles(document.body, {overflow: 'hidden'});
setStyles(document.documentElement, {overflow: 'hidden'});

iframe = document.createElement('iframe');
setStyles(iframe, {
position: 'fixed',
top: '5vh',
left: '5vw',
'z-index': 2147483647,
width: '90vw',
'max-width': 'none',
'min-width': 0,
height: '90vh',
'max-height': 'none',
'min-height': 0,
border: 0,
'border-radius': '10px',
background: '#fff',
'box-shadow': '0 25px 50px rgba(0, 0, 0, 0.6)',
'overscroll-behavior': 'contain',
});

iframe.src = scriptBase + 'store.html';
document.body.appendChild(iframe);
});

}).then(() => {
document.location.href = scriptBase + 'linter.html';
iframe.src = scriptBase + 'linter.html';
}).catch(err => {
alert(err);
document.location.reload();
Expand Down
7 changes: 7 additions & 0 deletions src/collector/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,13 @@ export default function (document, includeDom = false) {
});
}

document.body.removeChild(iframe);
document.body.removeChild(progressBar);
document.body.removeChild(progressMessage);
document.body.removeChild(overlay);
setStyles(document.body, {overflow: ''});
setStyles(document.documentElement, {overflow: ''});

return data;

});
Expand Down
1 change: 1 addition & 0 deletions src/reporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export default function (data) {

let link = document.createElement('a');
link.href = link.textContent = data.href;
link.target = '_top';
headline.appendChild(link);

let viewSettings = document.createElement('input');
Expand Down

0 comments on commit 194f755

Please sign in to comment.