Closed Bug 1444064 Opened 7 years ago Closed 5 years ago

Improve testing the browser toolbox

Categories

(DevTools :: Framework, enhancement, P3)

enhancement

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: ochameau, Assigned: bhackett1024)

References

(Depends on 1 open bug, Blocks 1 open bug)

Details

Attachments

(3 files, 1 obsolete file)

For now, testing the browser toolbox is possible. But it is very hacky, full of limitation and very hard to debug. See these three existing tests: https://searchfox.org/mozilla-central/source/devtools/client/aboutdebugging/test/browser_addons_debug_bootstrapped.js#66 https://searchfox.org/mozilla-central/source/devtools/client/framework/test/browser_browser_toolbox.js#45 https://searchfox.org/mozilla-central/source/devtools/client/framework/test/browser_browser_toolbox.js#45 It is based on an env variable, in which we put a Javascript code as string. It appears that it has a limited length, that, when reached will start throwing on Windows. We can't import any test scripts (files references in supports-files) and only files packaged in firefox. So we end up merging multiple files into this strings, which makes it very hard to know when an exception really came from. It isn't clear what we should do, but any little improvement will be good to take. I was wondering for example if we could: * have an equivalent of ContentTask for connected to the browser toolbox via RDP or something... * find a way to import support-files somehow * instead of evaluating a string, evaluate a given module
Severity: normal → enhancement
Priority: -- → P3
Product: Firefox → DevTools
Assignee: nobody → bhackett1024
Attached patch WIP (deleted) — Splinter Review

This patch is going in the direction of using the debugger protocol to implement something like ContentTask. This allows the test to trigger activity in the browser toolbox and then block (via await) until that activity completes. Something like this is necessary for tests which need to ensure that things happen in a well defined order.

The interfaces here are very much a WIP, but this adds a new global front living under the root front (named "toolbox" and in dire need of a rename) with methods that allows the server (where the test lives) to perform evaluations in the client (where the browser toolbox lives), provided that the testing only devtools.browser-toolbox.allow-unsafe-script preference is set. This is far enough along that the server can trigger an eval in the client and get the result.

This patch adds a browserToolboxTest actor which the server can use to perform evaluations in a sandbox in the client. It is only usable in tests that use the browser toolbox. This patch also adds a couple tests which use this, for making sure that the console shows messages from newly opened tabs and that the debugger updates its content process list when tabs are opened or closed. These tests both depend on bug 1586359.

Depends on: 1586359

Also, we still can't import test scripts here. URLs for testing files only seem to load in the original firefox instance. The tests here get around this by stringifying the testing functions they need and including them in the evaluated scripts, but this strategy will only work with simple functions.

Depends on: 1589864
Attachment #9100028 - Attachment description: Bug 1444064 - Add browserToolboxTest actor for communicating with the browser toolbox during tests, r=ochameau. → Bug 1444064 - Add ToolboxTask object for communicating with the browser toolbox during tests, r=ochameau.
Pushed by bhackett@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/62c82066ae44 Add ToolboxTask object for communicating with the browser toolbox during tests, r=ochameau.

Part 3 should be able to land later today. I'm not sure yet if I'll be able to land the test in part 2 --- it hasn't been very easy to control which processes the browser spawns when running longer test suites.

Whiteboard: leave-open
Attachment #9100211 - Attachment is obsolete: true
Pushed by bhackett@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/97d92c251ce1 Part 3 - Add test that OBT web console listens to new processes, r=nchevobbe.
Status: NEW → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
Whiteboard: leave-open
Depends on: 1591061
Depends on: 1591064
Regressions: 1591108
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: