fate0 / pychrome

A Python Package for the Google Chrome Dev Protocol [threading base]
Other
612 stars 112 forks source link

Chrome update from v71 to v72 broke request interception inside cross-domain iframes #36

Open jwray1 opened 5 years ago

jwray1 commented 5 years ago

Here's some minimal code to demonstrate the problem. In chrome 71, every request is intercepted and printed. In chrome 72, requests inside cross domain iframes do not even get to "Hello World"

import pychrome
REQUEST_INTERCEPT_PATTERNS = [{"urlPattern": "*", "interceptionStage": "HeadersReceived"}]
def request_intercepted(interceptionId, request, **kwargs):
    print('HELLO WORLD')
    body = tab.Network.getResponseBodyForInterception(interceptionId=interceptionId)['body']
    print(body)
    tab.Network.continueInterceptedRequest(interceptionId=interceptionId)

if __name__ == '__main__':
    browser = pychrome.Browser(url="http://127.0.0.1:9200")
    tab = browser.list_tab()[0]
    tab.Network.requestIntercepted = request_intercepted
    tab.start()
    tab.Page.enable()
    print(tab.Network)
    tab.Network.setRequestInterception(patterns=REQUEST_INTERCEPT_PATTERNS)