summaryrefslogtreecommitdiffstats
path: root/remote/shared/messagehandler/test/browser/webdriver/browser_session_execute_command_errors.js
blob: 36a510bb29dc309ab508819f7d530e3aafeee7d1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/* Any copyright is dedicated to the Public Domain.
 * http://creativecommons.org/publicdomain/zero/1.0/ */

"use strict";

const { WebDriverSession } = ChromeUtils.importESModule(
  "chrome://remote/content/shared/webdriver/Session.sys.mjs"
);

const { error } = ChromeUtils.importESModule(
  "chrome://remote/content/shared/webdriver/Errors.sys.mjs"
);

add_task(async function test_execute_missing_command_error() {
  const session = new WebDriverSession();

  info("Attempt to execute an unknown protocol command");
  await Assert.rejects(
    session.execute("command", "missingCommand"),
    err =>
      err.name == "UnknownCommandError" &&
      err.message == `command.missingCommand`
  );
});

add_task(async function test_execute_missing_internal_command_error() {
  const session = new WebDriverSession();

  info(
    "Attempt to execute a protocol command which relies on an unknown internal method"
  );
  await Assert.rejects(
    session.execute("command", "testMissingIntermediaryMethod"),
    err =>
      err.name == "UnsupportedCommandError" &&
      err.message ==
        `command.missingMethod not supported for destination ROOT` &&
      !error.isWebDriverError(err)
  );
});