Open Bug 1423868 Opened 7 years ago Updated 2 years ago

An example of typical Network panel test

Categories

(DevTools :: Netmonitor, enhancement, P3)

enhancement

Tracking

(Not tracked)

People

(Reporter: Honza, Unassigned)

References

Details

It would be great to have an example of typical Network panel test showing concepts that are often repeated. This should help us to produce new clean & stable tests in the future).

The example should show:

1) How to initialize Network monitor panel
2) How to trigger an HTTP request and wait till all (payload) data are fetched from the backend.
3) How to wait till the UI is properly updated (also happens asynchronously)
4) How to assert simple UI value.

Honza
Priority: -- → P1
Assignee: nobody → poirot.alex
Take browser_net_headers_sorted.js for example,

https://hg.mozilla.org/try/diff/58e23ac4f349/devtools/client/netmonitor/test/browser_net_headers_sorted.js#l1.31

After fetching requestHeaders & responseHeaders lazily, it's inevitable to add an extra wait code (waitUntil or waitForDOM) for ensuring every check is right. This trick is similar to what we use like onResponseContent [1] or waitForDOM to wait the component rendering state.

P.S. The waitForNetworkEvents of this test is in wrong order, so I moved it prior to tab.linkedBrowser.reload() to make it more solid. Please ignore the change of waitForNetworkEvents() in this case.

[1] https://searchfox.org/mozilla-central/source/devtools/client/netmonitor/test/browser_net_content-type.js#274
Another one is browser_net_filter-01.js 

https://hg.mozilla.org/try/diff/58e23ac4f349/devtools/client/netmonitor/test/browser_net_filter-01.js#l1.21


Filter request list needs to know requestHeaders & responseHeaders, both of them now are fetching lazily when filtering XHR & WS [1]. Therefore, while user clicks on filter buttons [2], we start fetching requestHeaders & responseHeaders via requestData [2]. It means RECEIVED_REQUEST_HEADERS & RECEIVED_RESPONSE_HEADERS events will be emitted under this condition. Both events will not appear in waitForNetworkEvents() calls.


[1] https://searchfox.org/mozilla-central/source/devtools/client/netmonitor/src/utils/filter-predicates.js#36,64
[2] https://hg.mozilla.org/try/diff/58e23ac4f349/devtools/client/netmonitor/src/components/RequestListItem.js#l1.71
Alex, you can use above two examples to extend what you want to do. Let's figure out how to improve our test env.
Flags: needinfo?(poirot.alex)
Flags: needinfo?(poirot.alex)
Product: Firefox → DevTools
@Alex: are you planning to work on this?

Or, should we move it to the Backlog (P3)?

Honza
Flags: needinfo?(poirot.alex)
TBH, I don't have the cycles to work on this right now.
I'm currently cleaning up many tests and I think there is more trivial cleanups to do first over the whole codebase.
Assignee: poirot.alex → nobody
Flags: needinfo?(poirot.alex)
Priority: P1 → P3
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.