• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2023 The Chromium Authors
2# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
4
5from __future__ import annotations
6
7from crossbench.browsers.applescript import AppleScriptBrowser
8from crossbench.browsers.attributes import BrowserAttributes
9from crossbench.browsers.chromium.chromium import Chromium
10
11
12# TODO: fix https://source.chromium.org/chromium/chromium/src/+/main:chrome/browser/ui/browser_commands_mac.mm;drc=ddf482c0cf47fc8e47e5cfc5c112e2313e066cb8;bpv=1;bpt=1;l=38
13# TODO: Auto-set: prefs::kAllowJavascriptAppleEvents
14# TODO: add --enable-automation flag
15class ChromiumAppleScript(Chromium, AppleScriptBrowser):
16  APPLE_SCRIPT_ALLOW_JS_MENU: str = (
17      "View > Developer > Allow JavaScript from Apple Events")
18  APPLE_SCRIPT_JS_COMMAND: str = (
19      "tell the active tab of front window to execute javascript %(js_script)s")
20  APPLE_SCRIPT_SET_URL: str = (
21      "set URL of the active tab of front window to %(url)s")
22
23  def _setup_window(self) -> None:
24    pass
25
26  @property
27  def attributes(self) -> BrowserAttributes:
28    return (BrowserAttributes.CHROMIUM | BrowserAttributes.CHROMIUM_BASED
29            | BrowserAttributes.APPLESCRIPT)
30