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

Implement Request.resourceType getter #590

Merged
merged 3 commits into from
Aug 29, 2017

Conversation

aslushnikov
Copy link
Contributor

This patch introduces Request.resourceType getter that represents resource type as it was perceived by the rendering engine. Possible values are inherited as-is from protocol:

  • Document, Stylesheet, Image, Media, Font, Script, TextTrack, XHR, Fetch, EventSource, WebSocket, Manifest, Other

This patch also updates an example to effectively block images.

This patch plumbs `resourceType` parameter of RequestWillBeSent
and requestIntercepted methods.
Copy link
Contributor

@JoelEinbinder JoelEinbinder left a comment

Choose a reason for hiding this comment

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

I will feel safer if we have a test that tests resourceType === 'Image'

@aslushnikov aslushnikov merged commit 11ce8b2 into puppeteer:master Aug 29, 2017
@gajus
Copy link

gajus commented Oct 8, 2017

Document, Stylesheet, Image, Media, Font, Script, TextTrack, XHR, Fetch, EventSource, WebSocket, Manifest, Other

It really bothers me that you are not using all caps or all lowercase convention.

Now every developer (cautious of hard to catch bugs) is going to need to add a safe-guard, such as request.resourceType.toUpperCase() === 'IMAGE'.

@ebidel
Copy link
Contributor

ebidel commented Oct 8, 2017

@gajus those values come from the DT protocol: https://chromedevtools.github.io/devtools-protocol/tot/Page/#type-ResourceType

@aslushnikov aslushnikov deleted the resource-type branch October 10, 2017 00:20
@aslushnikov
Copy link
Contributor Author

@gajus good point. Sent a PR to fix this: #990

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.

4 participants