diff options
author | Lars-Dominik Braun <lars@6xq.net> | 2019-10-19 11:17:41 +0200 |
---|---|---|
committer | Lars-Dominik Braun <lars@6xq.net> | 2019-10-19 11:17:41 +0200 |
commit | 68d0b84f8a6433ab3e9f76ef7a87fbbab39170cf (patch) | |
tree | c546282f0f6c7645adfcc343ad0e6ab1edd268ca /crocoite | |
parent | 75fe0d7dec4f8c06f29c861282c10b99d0d664f8 (diff) | |
download | crocoite-68d0b84f8a6433ab3e9f76ef7a87fbbab39170cf.tar.gz crocoite-68d0b84f8a6433ab3e9f76ef7a87fbbab39170cf.tar.bz2 crocoite-68d0b84f8a6433ab3e9f76ef7a87fbbab39170cf.zip |
devtools: Fix load testcase
Handle new *ExtraInfo events, but do not use them in browser yet, since
they’re still marked experimental.
Diffstat (limited to 'crocoite')
-rw-r--r-- | crocoite/test_devtools.py | 53 |
1 files changed, 35 insertions, 18 deletions
diff --git a/crocoite/test_devtools.py b/crocoite/test_devtools.py index 56fc42a..bd1a828 100644 --- a/crocoite/test_devtools.py +++ b/crocoite/test_devtools.py @@ -114,24 +114,41 @@ async def test_load (tab, server): await tab.Network.enable () await tab.Page.navigate (url='http://localhost:8080') - method, req = await tab.get () - assert method == tab.Network.requestWillBeSent - - method, resp = await tab.get () - assert method == tab.Network.responseReceived - assert resp['requestId'] == req['requestId'] - - method, dataRecv = await tab.get () - assert method == tab.Network.dataReceived - assert dataRecv['dataLength'] == len (docBody) - assert dataRecv['requestId'] == req['requestId'] - - method, finish = await tab.get () - assert method == tab.Network.loadingFinished - assert finish['requestId'] == req['requestId'] - - body = await tab.Network.getResponseBody (requestId=req['requestId']) - assert body['body'] == docBody + haveRequest = False + haveResponse = False + haveData = False + haveFinished = False + haveBody = False + req = None + resp = None + while not haveBody: + method, data = await tab.get () + + # it can be either of those two in no specified order + if method in (tab.Network.requestWillBeSent, tab.Network.requestWillBeSentExtraInfo) and not haveResponse: + if req is None: + req = data + assert data['requestId'] == req['requestId'] + haveRequest = True + elif method in (tab.Network.responseReceived, tab.Network.responseReceivedExtraInfo) and haveRequest: + if resp is None: + resp = data + assert data['requestId'] == resp['requestId'] + haveResponse = True + elif haveRequest and haveResponse and method == tab.Network.dataReceived: + assert data['dataLength'] == len (docBody) + assert data['requestId'] == req['requestId'] + haveData = True + elif haveData: + assert method == tab.Network.loadingFinished + assert data['requestId'] == req['requestId'] + haveBody = True + elif haveFinished: + body = await tab.Network.getResponseBody (requestId=req['requestId']) + assert body['body'] == docBody + haveBody = True + else: + assert False, (method, req) await tab.Network.disable () assert tab.pending == 0 |