Closed Bug 1790473 Opened 2 years ago Closed 2 years ago

Convert /remote/cdp JSM modules to ESM

Categories

(Remote Protocol :: Agent, task, P1)

task
Points:
1

Tracking

(firefox107 fixed)

RESOLVED FIXED
107 Branch
Tracking Status
firefox107 --- fixed

People

(Reporter: whimboo, Assigned: jdescottes)

References

Details

(Whiteboard: [webdriver:m5] [esmification-timeline])

Attachments

(2 files)

Once all the shared modules have been converted to ESM modules over on bug 1790468 all the files under remote/cdp can be converted as well.

Priority: -- → P1
Whiteboard: [webdriver:m5][esmification-timeline] → [webdriver:m5] [esmification-timeline]
Assignee: nobody → jdescottes
Status: NEW → ASSIGNED

Depends on D158298

Mark, Arai,

Quick question about frame scripts, as we have one in this folder: https://searchfox.org/mozilla-central/source/remote/cdp/sessions/frame-script.js

Should they be migrated to ESMs? It seems to work (or rather it doesn't seem to break) if I just manually rename them to sys.mjs (and ignore the eslint warning related to the usage of this, but I don't know if they are actually loaded as ESMs or just as a regular js file.

Flags: needinfo?(standard8)
Flags: needinfo?(arai.unmht)
See Also: → 1792976

(In reply to Julian Descottes [:jdescottes] from comment #3)

Should they be migrated to ESMs? It seems to work (or rather it doesn't seem to break) if I just manually rename them to sys.mjs (and ignore the eslint warning related to the usage of this, but I don't know if they are actually loaded as ESMs or just as a regular js file.

I think Arai would be best to answer this. I do know that we don't yet support workers as ES modules, but I don't know how frame scripts work. The fact that this works for it currently suggests that it isn't being loaded as a module.

Flags: needinfo?(standard8)

Frame script does not support ESM, and it's always regular script.

https://searchfox.org/mozilla-central/rev/f36f074acc09f2dab0e9ffaba34b5f6714dec81d/dom/base/nsFrameMessageManager.cpp#1201-1204,1308

already_AddRefed<JS::Stencil>
nsMessageManagerScriptExecutor::TryCacheLoadAndCompileScript(
    const nsAString& aURL, bool aRunInUniqueScope,
    JS::Handle<JSObject*> aMessageManager) {
...
    stencil = JS::CompileGlobalScriptToStencil(cx, options, srcBuf);

to my understanding, the file extension doesn't matter, but import / export syntax doesn't work there.

Flags: needinfo?(arai.unmht)

Great! Thanks for the quick feedback :)

Pushed by jdescottes@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/407ee0d19e23
[cdp] Convert /remote/cdp JSM modules to ESM r=webdriver-reviewers,whimboo
https://hg.mozilla.org/integration/autoland/rev/256e9641f5ae
[remote] Remove remote/.eslintrc.js r=webdriver-reviewers,whimboo
Status: ASSIGNED → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → 107 Branch
No longer regressions: 1793588
See Also: → 1793588
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: