Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(Page): Page.addScriptTag should throw when blocked by CSP #2320

Merged
merged 3 commits into from Apr 6, 2018

Conversation

aslushnikov
Copy link
Contributor

This patch teaches Page.addScriptTag and Page.addStyleTag to throw
an error when blocked by CSP.

References #1229.

This patch teaches Page.addScriptTag and Page.addStyleTag to throw
an error when blocked by CSP.

References puppeteer#1229.
@aslushnikov aslushnikov changed the title DevTools: Page.addScriptTagshould throw when blocked by CSP DevTools: Page.addScriptTag should throw when blocked by CSP Apr 6, 2018
@aslushnikov aslushnikov changed the title DevTools: Page.addScriptTag should throw when blocked by CSP feat(Page): Page.addScriptTag should throw when blocked by CSP Apr 6, 2018
script.onerror = rej;
});
return script;
document.head.appendChild(script);
return promise;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit:

await promise;
return script;

Makes this a bit easier to read. I missed that we were returning the script at first.

*/
function addStyleContent(content) {
const style = document.createElement('style');
style.type = 'text/css';
style.appendChild(document.createTextNode(content));
const promise = new Promise((res, rej) => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same comment as above.

@aslushnikov aslushnikov merged commit 846c080 into puppeteer:master Apr 6, 2018
@aslushnikov aslushnikov deleted the addscriptag-throws-on-csp branch May 9, 2018 01:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants