Closed Bug 1723592 Opened 3 years ago Closed 2 years ago

MessageHandler: Modules should explicitly declare their public commands and events

Categories

(Remote Protocol :: WebDriver BiDi, task, P2)

task
Points:
2

Tracking

(firefox97 fixed)

RESOLVED FIXED
97 Branch
Tracking Status
firefox97 --- fixed

People

(Reporter: jdescottes, Assigned: jdescottes)

References

(Blocks 1 open bug)

Details

(Whiteboard: [bidi-m3-mvp], [wptsync upstream])

Attachments

(2 files)

In Bug 1713439, we consider that all the methods implemented by a module class can be called as commands.

See the following method: https://searchfox.org/mozilla-central/rev/7b1de5e29d878cc163dec7beaf9b57a2f0f41aaa/remote/shared/messagehandler/MessageHandler.jsm#135-141

  _isCommandSupportedByModule(commandName, mod) {
    // TODO: With the current implementation, all functions of a given module
    // are considered as valid commands.
    // This should probably be replaced by a more explicit declaration, via a
    // manifest for instance.
    return mod && typeof mod[commandName] === "function";
  }

However we should prevent external consumers from calling methods which are not intended as public commands.

The goal of this bug is to add a proper implementation for _isCommandSupportedByModule which instead of checking for the existence of a function will check against a list exposed by the module. Alternatively, if we have a base Module class, we could add a generic supportsCommand method on this base class.

Note that internally, Modules also rely on commands to call one another. For those internal calls, we should not be limited to only public methods. So we need this API to make the distinction between an external call and an internal one. For internal calls, we might just reuse the current logic (ie allow to call any implemented method).

In a first step we don't necessarily have to support this granularity and we can just add all necessary commands as public ones.

Priority: -- → P3
Whiteboard: [webdriver:triage] → [bidi-m1-mvp]
See Also: → 1724411
Depends on: 1726800
Whiteboard: [bidi-m1-mvp] → [bidi-m2-mvp]
Priority: P3 → --

To be able to determine if a module supports a given command we definitely need this feature in M2.

Priority: -- → P2
Points: --- → 2

Updating the title to also mention "events", which would be useful in order to move the subscribe logic fully to the root session module.

Summary: MessageHandler: Modules should explicitly declare their public commands → MessageHandler: Modules should explicitly declare their public commands and events
Blocks: 1741861
Priority: P2 → P3
Assignee: nobody → jdescottes
Status: NEW → ASSIGNED
Priority: P3 → P2
Whiteboard: [bidi-m2-mvp] → [bidi-m3-mvp]
Attachment #9255577 - Attachment description: Bug 1723592 - [remote] Throw InvalidArgumentException when passing events with invalid modules to session subscribe/unsubscribe → Bug 1723592 - [remote] Throw InvalidArgumentException when passing invalid events to session subscribe/unsubscribe
Pushed by jdescottes@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/d0a8287451b3
[remote] Throw InvalidArgumentException when passing invalid events to session subscribe/unsubscribe r=webdriver-reviewers,whimboo
https://hg.mozilla.org/integration/autoland/rev/aaf6e76bcdb7
[wdspec] Update wdspec tests to test unsupported events in session module r=webdriver-reviewers,whimboo
Created web-platform-tests PR https://github.com/web-platform-tests/wpt/pull/32245 for changes under testing/web-platform/tests
Whiteboard: [bidi-m3-mvp] → [bidi-m3-mvp], [wptsync upstream]
Status: ASSIGNED → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → 97 Branch
Upstream PR merged by moz-wptsync-bot
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: