11cb0ef41Sopenharmony_ci(function() {
21cb0ef41Sopenharmony_ci    "use strict";
31cb0ef41Sopenharmony_ci    var idCounter = 0;
41cb0ef41Sopenharmony_ci    let testharness_context = null;
51cb0ef41Sopenharmony_ci
61cb0ef41Sopenharmony_ci    function getInViewCenterPoint(rect) {
71cb0ef41Sopenharmony_ci        var left = Math.max(0, rect.left);
81cb0ef41Sopenharmony_ci        var right = Math.min(window.innerWidth, rect.right);
91cb0ef41Sopenharmony_ci        var top = Math.max(0, rect.top);
101cb0ef41Sopenharmony_ci        var bottom = Math.min(window.innerHeight, rect.bottom);
111cb0ef41Sopenharmony_ci
121cb0ef41Sopenharmony_ci        var x = 0.5 * (left + right);
131cb0ef41Sopenharmony_ci        var y = 0.5 * (top + bottom);
141cb0ef41Sopenharmony_ci
151cb0ef41Sopenharmony_ci        return [x, y];
161cb0ef41Sopenharmony_ci    }
171cb0ef41Sopenharmony_ci
181cb0ef41Sopenharmony_ci    function getPointerInteractablePaintTree(element) {
191cb0ef41Sopenharmony_ci        let elementDocument = element.ownerDocument;
201cb0ef41Sopenharmony_ci        if (!elementDocument.contains(element)) {
211cb0ef41Sopenharmony_ci            return [];
221cb0ef41Sopenharmony_ci        }
231cb0ef41Sopenharmony_ci
241cb0ef41Sopenharmony_ci        var rectangles = element.getClientRects();
251cb0ef41Sopenharmony_ci
261cb0ef41Sopenharmony_ci        if (rectangles.length === 0) {
271cb0ef41Sopenharmony_ci            return [];
281cb0ef41Sopenharmony_ci        }
291cb0ef41Sopenharmony_ci
301cb0ef41Sopenharmony_ci        var centerPoint = getInViewCenterPoint(rectangles[0]);
311cb0ef41Sopenharmony_ci
321cb0ef41Sopenharmony_ci        if ("elementsFromPoint" in elementDocument) {
331cb0ef41Sopenharmony_ci            return elementDocument.elementsFromPoint(centerPoint[0], centerPoint[1]);
341cb0ef41Sopenharmony_ci        } else if ("msElementsFromPoint" in elementDocument) {
351cb0ef41Sopenharmony_ci            var rv = elementDocument.msElementsFromPoint(centerPoint[0], centerPoint[1]);
361cb0ef41Sopenharmony_ci            return Array.prototype.slice.call(rv ? rv : []);
371cb0ef41Sopenharmony_ci        } else {
381cb0ef41Sopenharmony_ci            throw new Error("document.elementsFromPoint unsupported");
391cb0ef41Sopenharmony_ci        }
401cb0ef41Sopenharmony_ci    }
411cb0ef41Sopenharmony_ci
421cb0ef41Sopenharmony_ci    function inView(element) {
431cb0ef41Sopenharmony_ci        var pointerInteractablePaintTree = getPointerInteractablePaintTree(element);
441cb0ef41Sopenharmony_ci        return pointerInteractablePaintTree.indexOf(element) !== -1;
451cb0ef41Sopenharmony_ci    }
461cb0ef41Sopenharmony_ci
471cb0ef41Sopenharmony_ci
481cb0ef41Sopenharmony_ci    /**
491cb0ef41Sopenharmony_ci     * @namespace {test_driver}
501cb0ef41Sopenharmony_ci     */
511cb0ef41Sopenharmony_ci    window.test_driver = {
521cb0ef41Sopenharmony_ci        /**
531cb0ef41Sopenharmony_ci         * Set the context in which testharness.js is loaded
541cb0ef41Sopenharmony_ci         *
551cb0ef41Sopenharmony_ci         * @param {WindowProxy} context - the window containing testharness.js
561cb0ef41Sopenharmony_ci         **/
571cb0ef41Sopenharmony_ci        set_test_context: function(context) {
581cb0ef41Sopenharmony_ci          if (window.test_driver_internal.set_test_context) {
591cb0ef41Sopenharmony_ci            window.test_driver_internal.set_test_context(context);
601cb0ef41Sopenharmony_ci          }
611cb0ef41Sopenharmony_ci          testharness_context = context;
621cb0ef41Sopenharmony_ci        },
631cb0ef41Sopenharmony_ci
641cb0ef41Sopenharmony_ci        /**
651cb0ef41Sopenharmony_ci         * postMessage to the context containing testharness.js
661cb0ef41Sopenharmony_ci         *
671cb0ef41Sopenharmony_ci         * @param {Object} msg - the data to POST
681cb0ef41Sopenharmony_ci         **/
691cb0ef41Sopenharmony_ci        message_test: function(msg) {
701cb0ef41Sopenharmony_ci            let target = testharness_context;
711cb0ef41Sopenharmony_ci            if (testharness_context === null) {
721cb0ef41Sopenharmony_ci                target = window;
731cb0ef41Sopenharmony_ci            }
741cb0ef41Sopenharmony_ci            target.postMessage(msg, "*");
751cb0ef41Sopenharmony_ci        },
761cb0ef41Sopenharmony_ci
771cb0ef41Sopenharmony_ci        /**
781cb0ef41Sopenharmony_ci         * Trigger user interaction in order to grant additional privileges to
791cb0ef41Sopenharmony_ci         * a provided function.
801cb0ef41Sopenharmony_ci         *
811cb0ef41Sopenharmony_ci         * See `triggered by user activation
821cb0ef41Sopenharmony_ci         * <https://html.spec.whatwg.org/#triggered-by-user-activation>`_.
831cb0ef41Sopenharmony_ci         *
841cb0ef41Sopenharmony_ci         * @example
851cb0ef41Sopenharmony_ci         * var mediaElement = document.createElement('video');
861cb0ef41Sopenharmony_ci         *
871cb0ef41Sopenharmony_ci         * test_driver.bless('initiate media playback', function () {
881cb0ef41Sopenharmony_ci         *   mediaElement.play();
891cb0ef41Sopenharmony_ci         * });
901cb0ef41Sopenharmony_ci         *
911cb0ef41Sopenharmony_ci         * @param {String} intent - a description of the action which must be
921cb0ef41Sopenharmony_ci         *                          triggered by user interaction
931cb0ef41Sopenharmony_ci         * @param {Function} action - code requiring escalated privileges
941cb0ef41Sopenharmony_ci         * @param {WindowProxy} context - Browsing context in which
951cb0ef41Sopenharmony_ci         *                                to run the call, or null for the current
961cb0ef41Sopenharmony_ci         *                                browsing context.
971cb0ef41Sopenharmony_ci         *
981cb0ef41Sopenharmony_ci         * @returns {Promise} fulfilled following user interaction and
991cb0ef41Sopenharmony_ci         *                    execution of the provided `action` function;
1001cb0ef41Sopenharmony_ci         *                    rejected if interaction fails or the provided
1011cb0ef41Sopenharmony_ci         *                    function throws an error
1021cb0ef41Sopenharmony_ci         */
1031cb0ef41Sopenharmony_ci        bless: function(intent, action, context=null) {
1041cb0ef41Sopenharmony_ci            let contextDocument = context ? context.document : document;
1051cb0ef41Sopenharmony_ci            var button = contextDocument.createElement("button");
1061cb0ef41Sopenharmony_ci            button.innerHTML = "This test requires user interaction.<br />" +
1071cb0ef41Sopenharmony_ci                "Please click here to allow " + intent + ".";
1081cb0ef41Sopenharmony_ci            button.id = "wpt-test-driver-bless-" + (idCounter += 1);
1091cb0ef41Sopenharmony_ci            const elem = contextDocument.body || contextDocument.documentElement;
1101cb0ef41Sopenharmony_ci            elem.appendChild(button);
1111cb0ef41Sopenharmony_ci
1121cb0ef41Sopenharmony_ci            let wait_click = new Promise(resolve => button.addEventListener("click", resolve));
1131cb0ef41Sopenharmony_ci
1141cb0ef41Sopenharmony_ci            return test_driver.click(button)
1151cb0ef41Sopenharmony_ci                .then(wait_click)
1161cb0ef41Sopenharmony_ci                .then(function() {
1171cb0ef41Sopenharmony_ci                    button.remove();
1181cb0ef41Sopenharmony_ci
1191cb0ef41Sopenharmony_ci                    if (typeof action === "function") {
1201cb0ef41Sopenharmony_ci                        return action();
1211cb0ef41Sopenharmony_ci                    }
1221cb0ef41Sopenharmony_ci                    return null;
1231cb0ef41Sopenharmony_ci                });
1241cb0ef41Sopenharmony_ci        },
1251cb0ef41Sopenharmony_ci
1261cb0ef41Sopenharmony_ci        /**
1271cb0ef41Sopenharmony_ci         * Triggers a user-initiated click
1281cb0ef41Sopenharmony_ci         *
1291cb0ef41Sopenharmony_ci         * If ``element`` isn't inside the
1301cb0ef41Sopenharmony_ci         * viewport, it will be scrolled into view before the click
1311cb0ef41Sopenharmony_ci         * occurs.
1321cb0ef41Sopenharmony_ci         *
1331cb0ef41Sopenharmony_ci         * If ``element`` is from a different browsing context, the
1341cb0ef41Sopenharmony_ci         * command will be run in that context.
1351cb0ef41Sopenharmony_ci         *
1361cb0ef41Sopenharmony_ci         * Matches the behaviour of the `Element Click
1371cb0ef41Sopenharmony_ci         * <https://w3c.github.io/webdriver/#element-click>`_
1381cb0ef41Sopenharmony_ci         * WebDriver command.
1391cb0ef41Sopenharmony_ci         *
1401cb0ef41Sopenharmony_ci         * **Note:** If the element to be clicked does not have a
1411cb0ef41Sopenharmony_ci         * unique ID, the document must not have any DOM mutations
1421cb0ef41Sopenharmony_ci         * made between the function being called and the promise
1431cb0ef41Sopenharmony_ci         * settling.
1441cb0ef41Sopenharmony_ci         *
1451cb0ef41Sopenharmony_ci         * @param {Element} element - element to be clicked
1461cb0ef41Sopenharmony_ci         * @returns {Promise} fulfilled after click occurs, or rejected in
1471cb0ef41Sopenharmony_ci         *                    the cases the WebDriver command errors
1481cb0ef41Sopenharmony_ci         */
1491cb0ef41Sopenharmony_ci        click: function(element) {
1501cb0ef41Sopenharmony_ci            if (!inView(element)) {
1511cb0ef41Sopenharmony_ci                element.scrollIntoView({behavior: "instant",
1521cb0ef41Sopenharmony_ci                                        block: "end",
1531cb0ef41Sopenharmony_ci                                        inline: "nearest"});
1541cb0ef41Sopenharmony_ci            }
1551cb0ef41Sopenharmony_ci
1561cb0ef41Sopenharmony_ci            var pointerInteractablePaintTree = getPointerInteractablePaintTree(element);
1571cb0ef41Sopenharmony_ci            if (pointerInteractablePaintTree.length === 0 ||
1581cb0ef41Sopenharmony_ci                !element.contains(pointerInteractablePaintTree[0])) {
1591cb0ef41Sopenharmony_ci                return Promise.reject(new Error("element click intercepted error"));
1601cb0ef41Sopenharmony_ci            }
1611cb0ef41Sopenharmony_ci
1621cb0ef41Sopenharmony_ci            var rect = element.getClientRects()[0];
1631cb0ef41Sopenharmony_ci            var centerPoint = getInViewCenterPoint(rect);
1641cb0ef41Sopenharmony_ci            return window.test_driver_internal.click(element,
1651cb0ef41Sopenharmony_ci                                                     {x: centerPoint[0],
1661cb0ef41Sopenharmony_ci                                                      y: centerPoint[1]});
1671cb0ef41Sopenharmony_ci        },
1681cb0ef41Sopenharmony_ci
1691cb0ef41Sopenharmony_ci        /**
1701cb0ef41Sopenharmony_ci         * Deletes all cookies.
1711cb0ef41Sopenharmony_ci         *
1721cb0ef41Sopenharmony_ci         * Matches the behaviour of the `Delete All Cookies
1731cb0ef41Sopenharmony_ci         * <https://w3c.github.io/webdriver/#delete-all-cookies>`_
1741cb0ef41Sopenharmony_ci         * WebDriver command.
1751cb0ef41Sopenharmony_ci         *
1761cb0ef41Sopenharmony_ci         * @param {WindowProxy} context - Browsing context in which
1771cb0ef41Sopenharmony_ci         *                                to run the call, or null for the current
1781cb0ef41Sopenharmony_ci         *                                browsing context.
1791cb0ef41Sopenharmony_ci         *
1801cb0ef41Sopenharmony_ci         * @returns {Promise} fulfilled after cookies are deleted, or rejected in
1811cb0ef41Sopenharmony_ci         *                    the cases the WebDriver command errors
1821cb0ef41Sopenharmony_ci         */
1831cb0ef41Sopenharmony_ci        delete_all_cookies: function(context=null) {
1841cb0ef41Sopenharmony_ci            return window.test_driver_internal.delete_all_cookies(context);
1851cb0ef41Sopenharmony_ci        },
1861cb0ef41Sopenharmony_ci
1871cb0ef41Sopenharmony_ci        /**
1881cb0ef41Sopenharmony_ci         * Send keys to an element.
1891cb0ef41Sopenharmony_ci         *
1901cb0ef41Sopenharmony_ci         * If ``element`` isn't inside the
1911cb0ef41Sopenharmony_ci         * viewport, it will be scrolled into view before the click
1921cb0ef41Sopenharmony_ci         * occurs.
1931cb0ef41Sopenharmony_ci         *
1941cb0ef41Sopenharmony_ci         * If ``element`` is from a different browsing context, the
1951cb0ef41Sopenharmony_ci         * command will be run in that context.
1961cb0ef41Sopenharmony_ci         *
1971cb0ef41Sopenharmony_ci         * To send special keys, send the respective key's codepoint,
1981cb0ef41Sopenharmony_ci         * as defined by `WebDriver
1991cb0ef41Sopenharmony_ci         * <https://w3c.github.io/webdriver/#keyboard-actions>`_.  For
2001cb0ef41Sopenharmony_ci         * example, the "tab" key is represented as "``\uE004``".
2011cb0ef41Sopenharmony_ci         *
2021cb0ef41Sopenharmony_ci         * **Note:** these special-key codepoints are not necessarily
2031cb0ef41Sopenharmony_ci         * what you would expect. For example, <kbd>Esc</kbd> is the
2041cb0ef41Sopenharmony_ci         * invalid Unicode character ``\uE00C``, not the ``\u001B`` Escape
2051cb0ef41Sopenharmony_ci         * character from ASCII.
2061cb0ef41Sopenharmony_ci         *
2071cb0ef41Sopenharmony_ci         * This matches the behaviour of the
2081cb0ef41Sopenharmony_ci         * `Send Keys
2091cb0ef41Sopenharmony_ci         * <https://w3c.github.io/webdriver/#element-send-keys>`_
2101cb0ef41Sopenharmony_ci         * WebDriver command.
2111cb0ef41Sopenharmony_ci         *
2121cb0ef41Sopenharmony_ci         * **Note:** If the element to be clicked does not have a
2131cb0ef41Sopenharmony_ci         * unique ID, the document must not have any DOM mutations
2141cb0ef41Sopenharmony_ci         * made between the function being called and the promise
2151cb0ef41Sopenharmony_ci         * settling.
2161cb0ef41Sopenharmony_ci         *
2171cb0ef41Sopenharmony_ci         * @param {Element} element - element to send keys to
2181cb0ef41Sopenharmony_ci         * @param {String} keys - keys to send to the element
2191cb0ef41Sopenharmony_ci         * @returns {Promise} fulfilled after keys are sent, or rejected in
2201cb0ef41Sopenharmony_ci         *                    the cases the WebDriver command errors
2211cb0ef41Sopenharmony_ci         */
2221cb0ef41Sopenharmony_ci        send_keys: function(element, keys) {
2231cb0ef41Sopenharmony_ci            if (!inView(element)) {
2241cb0ef41Sopenharmony_ci                element.scrollIntoView({behavior: "instant",
2251cb0ef41Sopenharmony_ci                                        block: "end",
2261cb0ef41Sopenharmony_ci                                        inline: "nearest"});
2271cb0ef41Sopenharmony_ci            }
2281cb0ef41Sopenharmony_ci
2291cb0ef41Sopenharmony_ci            var pointerInteractablePaintTree = getPointerInteractablePaintTree(element);
2301cb0ef41Sopenharmony_ci            if (pointerInteractablePaintTree.length === 0 ||
2311cb0ef41Sopenharmony_ci                !element.contains(pointerInteractablePaintTree[0])) {
2321cb0ef41Sopenharmony_ci                return Promise.reject(new Error("element send_keys intercepted error"));
2331cb0ef41Sopenharmony_ci            }
2341cb0ef41Sopenharmony_ci
2351cb0ef41Sopenharmony_ci            return window.test_driver_internal.send_keys(element, keys);
2361cb0ef41Sopenharmony_ci        },
2371cb0ef41Sopenharmony_ci
2381cb0ef41Sopenharmony_ci        /**
2391cb0ef41Sopenharmony_ci         * Freeze the current page
2401cb0ef41Sopenharmony_ci         *
2411cb0ef41Sopenharmony_ci         * The freeze function transitions the page from the HIDDEN state to
2421cb0ef41Sopenharmony_ci         * the FROZEN state as described in `Lifecycle API for Web Pages
2431cb0ef41Sopenharmony_ci         * <https://github.com/WICG/page-lifecycle/blob/master/README.md>`_.
2441cb0ef41Sopenharmony_ci         *
2451cb0ef41Sopenharmony_ci         * @param {WindowProxy} context - Browsing context in which
2461cb0ef41Sopenharmony_ci         *                                to run the call, or null for the current
2471cb0ef41Sopenharmony_ci         *                                browsing context.
2481cb0ef41Sopenharmony_ci         *
2491cb0ef41Sopenharmony_ci         * @returns {Promise} fulfilled after the freeze request is sent, or rejected
2501cb0ef41Sopenharmony_ci         *                    in case the WebDriver command errors
2511cb0ef41Sopenharmony_ci         */
2521cb0ef41Sopenharmony_ci        freeze: function(context=null) {
2531cb0ef41Sopenharmony_ci            return window.test_driver_internal.freeze();
2541cb0ef41Sopenharmony_ci        },
2551cb0ef41Sopenharmony_ci
2561cb0ef41Sopenharmony_ci        /**
2571cb0ef41Sopenharmony_ci         * Minimizes the browser window.
2581cb0ef41Sopenharmony_ci         *
2591cb0ef41Sopenharmony_ci         * Matches the the behaviour of the `Minimize
2601cb0ef41Sopenharmony_ci         * <https://www.w3.org/TR/webdriver/#minimize-window>`_
2611cb0ef41Sopenharmony_ci         * WebDriver command
2621cb0ef41Sopenharmony_ci         *
2631cb0ef41Sopenharmony_ci         * @param {WindowProxy} context - Browsing context in which
2641cb0ef41Sopenharmony_ci         *                                to run the call, or null for the current
2651cb0ef41Sopenharmony_ci         *                                browsing context.
2661cb0ef41Sopenharmony_ci         *
2671cb0ef41Sopenharmony_ci         * @returns {Promise} fulfilled with the previous {@link
2681cb0ef41Sopenharmony_ci         *                    https://www.w3.org/TR/webdriver/#dfn-windowrect-object|WindowRect}
2691cb0ef41Sopenharmony_ci         *                      value, after the window is minimized.
2701cb0ef41Sopenharmony_ci         */
2711cb0ef41Sopenharmony_ci        minimize_window: function(context=null) {
2721cb0ef41Sopenharmony_ci            return window.test_driver_internal.minimize_window(context);
2731cb0ef41Sopenharmony_ci        },
2741cb0ef41Sopenharmony_ci
2751cb0ef41Sopenharmony_ci        /**
2761cb0ef41Sopenharmony_ci         * Restore the window from minimized/maximized state to a given rect.
2771cb0ef41Sopenharmony_ci         *
2781cb0ef41Sopenharmony_ci         * Matches the behaviour of the `Set Window Rect
2791cb0ef41Sopenharmony_ci         * <https://www.w3.org/TR/webdriver/#set-window-rect>`_
2801cb0ef41Sopenharmony_ci         * WebDriver command
2811cb0ef41Sopenharmony_ci         *
2821cb0ef41Sopenharmony_ci         * @param {Object} rect - A {@link
2831cb0ef41Sopenharmony_ci         *                           https://www.w3.org/TR/webdriver/#dfn-windowrect-object|WindowRect}
2841cb0ef41Sopenharmony_ci         * @param {WindowProxy} context - Browsing context in which
2851cb0ef41Sopenharmony_ci         *                                to run the call, or null for the current
2861cb0ef41Sopenharmony_ci         *                                browsing context.
2871cb0ef41Sopenharmony_ci         *
2881cb0ef41Sopenharmony_ci         * @returns {Promise} fulfilled after the window is restored to the given rect.
2891cb0ef41Sopenharmony_ci         */
2901cb0ef41Sopenharmony_ci        set_window_rect: function(rect, context=null) {
2911cb0ef41Sopenharmony_ci            return window.test_driver_internal.set_window_rect(rect, context);
2921cb0ef41Sopenharmony_ci        },
2931cb0ef41Sopenharmony_ci
2941cb0ef41Sopenharmony_ci        /**
2951cb0ef41Sopenharmony_ci         * Send a sequence of actions
2961cb0ef41Sopenharmony_ci         *
2971cb0ef41Sopenharmony_ci         * This function sends a sequence of actions to perform.
2981cb0ef41Sopenharmony_ci         *
2991cb0ef41Sopenharmony_ci         * Matches the behaviour of the `Actions
3001cb0ef41Sopenharmony_ci         * <https://w3c.github.io/webdriver/#actions>`_ feature in
3011cb0ef41Sopenharmony_ci         * WebDriver.
3021cb0ef41Sopenharmony_ci         *
3031cb0ef41Sopenharmony_ci         * Authors are encouraged to use the
3041cb0ef41Sopenharmony_ci         * :js:class:`test_driver.Actions` builder rather than
3051cb0ef41Sopenharmony_ci         * invoking this API directly.
3061cb0ef41Sopenharmony_ci         *
3071cb0ef41Sopenharmony_ci         * @param {Array} actions - an array of actions. The format is
3081cb0ef41Sopenharmony_ci         *                          the same as the actions property
3091cb0ef41Sopenharmony_ci         *                          of the `Perform Actions
3101cb0ef41Sopenharmony_ci         *                          <https://w3c.github.io/webdriver/#perform-actions>`_
3111cb0ef41Sopenharmony_ci         *                          WebDriver command. Each element is
3121cb0ef41Sopenharmony_ci         *                          an object representing an input
3131cb0ef41Sopenharmony_ci         *                          source and each input source
3141cb0ef41Sopenharmony_ci         *                          itself has an actions property
3151cb0ef41Sopenharmony_ci         *                          detailing the behaviour of that
3161cb0ef41Sopenharmony_ci         *                          source at each timestep (or
3171cb0ef41Sopenharmony_ci         *                          tick). Authors are not expected to
3181cb0ef41Sopenharmony_ci         *                          construct the actions sequence by
3191cb0ef41Sopenharmony_ci         *                          hand, but to use the builder api
3201cb0ef41Sopenharmony_ci         *                          provided in testdriver-actions.js
3211cb0ef41Sopenharmony_ci         * @param {WindowProxy} context - Browsing context in which
3221cb0ef41Sopenharmony_ci         *                                to run the call, or null for the current
3231cb0ef41Sopenharmony_ci         *                                browsing context.
3241cb0ef41Sopenharmony_ci         *
3251cb0ef41Sopenharmony_ci         * @returns {Promise} fulfilled after the actions are performed, or rejected in
3261cb0ef41Sopenharmony_ci         *                    the cases the WebDriver command errors
3271cb0ef41Sopenharmony_ci         */
3281cb0ef41Sopenharmony_ci        action_sequence: function(actions, context=null) {
3291cb0ef41Sopenharmony_ci            return window.test_driver_internal.action_sequence(actions, context);
3301cb0ef41Sopenharmony_ci        },
3311cb0ef41Sopenharmony_ci
3321cb0ef41Sopenharmony_ci        /**
3331cb0ef41Sopenharmony_ci         * Generates a test report on the current page
3341cb0ef41Sopenharmony_ci         *
3351cb0ef41Sopenharmony_ci         * The generate_test_report function generates a report (to be
3361cb0ef41Sopenharmony_ci         * observed by ReportingObserver) for testing purposes.
3371cb0ef41Sopenharmony_ci         *
3381cb0ef41Sopenharmony_ci         * Matches the `Generate Test Report
3391cb0ef41Sopenharmony_ci         * <https://w3c.github.io/reporting/#generate-test-report-command>`_
3401cb0ef41Sopenharmony_ci         * WebDriver command.
3411cb0ef41Sopenharmony_ci         *
3421cb0ef41Sopenharmony_ci         * @param {WindowProxy} context - Browsing context in which
3431cb0ef41Sopenharmony_ci         *                                to run the call, or null for the current
3441cb0ef41Sopenharmony_ci         *                                browsing context.
3451cb0ef41Sopenharmony_ci         *
3461cb0ef41Sopenharmony_ci         * @returns {Promise} fulfilled after the report is generated, or
3471cb0ef41Sopenharmony_ci         *                    rejected if the report generation fails
3481cb0ef41Sopenharmony_ci         */
3491cb0ef41Sopenharmony_ci        generate_test_report: function(message, context=null) {
3501cb0ef41Sopenharmony_ci            return window.test_driver_internal.generate_test_report(message, context);
3511cb0ef41Sopenharmony_ci        },
3521cb0ef41Sopenharmony_ci
3531cb0ef41Sopenharmony_ci        /**
3541cb0ef41Sopenharmony_ci         * Sets the state of a permission
3551cb0ef41Sopenharmony_ci         *
3561cb0ef41Sopenharmony_ci         * This function simulates a user setting a permission into a
3571cb0ef41Sopenharmony_ci         * particular state.
3581cb0ef41Sopenharmony_ci         *
3591cb0ef41Sopenharmony_ci         * Matches the `Set Permission
3601cb0ef41Sopenharmony_ci         * <https://w3c.github.io/permissions/#set-permission-command>`_
3611cb0ef41Sopenharmony_ci         * WebDriver command.
3621cb0ef41Sopenharmony_ci         *
3631cb0ef41Sopenharmony_ci         * @example
3641cb0ef41Sopenharmony_ci         * await test_driver.set_permission({ name: "background-fetch" }, "denied");
3651cb0ef41Sopenharmony_ci         * await test_driver.set_permission({ name: "push", userVisibleOnly: true }, "granted", true);
3661cb0ef41Sopenharmony_ci         *
3671cb0ef41Sopenharmony_ci         * @param {Object} descriptor - a `PermissionDescriptor
3681cb0ef41Sopenharmony_ci         *                              <https://w3c.github.io/permissions/#dictdef-permissiondescriptor>`_
3691cb0ef41Sopenharmony_ci         *                              object
3701cb0ef41Sopenharmony_ci         * @param {String} state - the state of the permission
3711cb0ef41Sopenharmony_ci         * @param {boolean} one_realm - Optional. Whether the permission applies to only one realm
3721cb0ef41Sopenharmony_ci         * @param {WindowProxy} context - Browsing context in which
3731cb0ef41Sopenharmony_ci         *                                to run the call, or null for the current
3741cb0ef41Sopenharmony_ci         *                                browsing context.
3751cb0ef41Sopenharmony_ci         * @returns {Promise} fulfilled after the permission is set, or rejected if setting the
3761cb0ef41Sopenharmony_ci         *                    permission fails
3771cb0ef41Sopenharmony_ci         */
3781cb0ef41Sopenharmony_ci        set_permission: function(descriptor, state, one_realm=false, context=null) {
3791cb0ef41Sopenharmony_ci            let permission_params = {
3801cb0ef41Sopenharmony_ci              descriptor,
3811cb0ef41Sopenharmony_ci              state,
3821cb0ef41Sopenharmony_ci              oneRealm: one_realm,
3831cb0ef41Sopenharmony_ci            };
3841cb0ef41Sopenharmony_ci            return window.test_driver_internal.set_permission(permission_params, context);
3851cb0ef41Sopenharmony_ci        },
3861cb0ef41Sopenharmony_ci
3871cb0ef41Sopenharmony_ci        /**
3881cb0ef41Sopenharmony_ci         * Creates a virtual authenticator
3891cb0ef41Sopenharmony_ci         *
3901cb0ef41Sopenharmony_ci         * This function creates a virtual authenticator for use with
3911cb0ef41Sopenharmony_ci         * the U2F and WebAuthn APIs.
3921cb0ef41Sopenharmony_ci         *
3931cb0ef41Sopenharmony_ci         * Matches the `Add Virtual Authenticator
3941cb0ef41Sopenharmony_ci         * <https://w3c.github.io/webauthn/#sctn-automation-add-virtual-authenticator>`_
3951cb0ef41Sopenharmony_ci         * WebDriver command.
3961cb0ef41Sopenharmony_ci         *
3971cb0ef41Sopenharmony_ci         * @param {Object} config - an `Authenticator Configuration
3981cb0ef41Sopenharmony_ci         *                          <https://w3c.github.io/webauthn/#authenticator-configuration>`_
3991cb0ef41Sopenharmony_ci         *                          object
4001cb0ef41Sopenharmony_ci         * @param {WindowProxy} context - Browsing context in which
4011cb0ef41Sopenharmony_ci         *                                to run the call, or null for the current
4021cb0ef41Sopenharmony_ci         *                                browsing context.
4031cb0ef41Sopenharmony_ci         *
4041cb0ef41Sopenharmony_ci         * @returns {Promise} fulfilled after the authenticator is added, or
4051cb0ef41Sopenharmony_ci         *                    rejected in the cases the WebDriver command
4061cb0ef41Sopenharmony_ci         *                    errors. Returns the ID of the authenticator
4071cb0ef41Sopenharmony_ci         */
4081cb0ef41Sopenharmony_ci        add_virtual_authenticator: function(config, context=null) {
4091cb0ef41Sopenharmony_ci            return window.test_driver_internal.add_virtual_authenticator(config, context);
4101cb0ef41Sopenharmony_ci        },
4111cb0ef41Sopenharmony_ci
4121cb0ef41Sopenharmony_ci        /**
4131cb0ef41Sopenharmony_ci         * Removes a virtual authenticator
4141cb0ef41Sopenharmony_ci         *
4151cb0ef41Sopenharmony_ci         * This function removes a virtual authenticator that has been
4161cb0ef41Sopenharmony_ci         * created by :js:func:`add_virtual_authenticator`.
4171cb0ef41Sopenharmony_ci         *
4181cb0ef41Sopenharmony_ci         * Matches the `Remove Virtual Authenticator
4191cb0ef41Sopenharmony_ci         * <https://w3c.github.io/webauthn/#sctn-automation-remove-virtual-authenticator>`_
4201cb0ef41Sopenharmony_ci         * WebDriver command.
4211cb0ef41Sopenharmony_ci         *
4221cb0ef41Sopenharmony_ci         * @param {String} authenticator_id - the ID of the authenticator to be
4231cb0ef41Sopenharmony_ci         *                                    removed.
4241cb0ef41Sopenharmony_ci         * @param {WindowProxy} context - Browsing context in which
4251cb0ef41Sopenharmony_ci         *                                to run the call, or null for the current
4261cb0ef41Sopenharmony_ci         *                                browsing context.
4271cb0ef41Sopenharmony_ci         *
4281cb0ef41Sopenharmony_ci         * @returns {Promise} fulfilled after the authenticator is removed, or
4291cb0ef41Sopenharmony_ci         *                    rejected in the cases the WebDriver command
4301cb0ef41Sopenharmony_ci         *                    errors
4311cb0ef41Sopenharmony_ci         */
4321cb0ef41Sopenharmony_ci        remove_virtual_authenticator: function(authenticator_id, context=null) {
4331cb0ef41Sopenharmony_ci            return window.test_driver_internal.remove_virtual_authenticator(authenticator_id, context);
4341cb0ef41Sopenharmony_ci        },
4351cb0ef41Sopenharmony_ci
4361cb0ef41Sopenharmony_ci        /**
4371cb0ef41Sopenharmony_ci         * Adds a credential to a virtual authenticator
4381cb0ef41Sopenharmony_ci         *
4391cb0ef41Sopenharmony_ci         * Matches the `Add Credential
4401cb0ef41Sopenharmony_ci         * <https://w3c.github.io/webauthn/#sctn-automation-add-credential>`_
4411cb0ef41Sopenharmony_ci         * WebDriver command.
4421cb0ef41Sopenharmony_ci         *
4431cb0ef41Sopenharmony_ci         * @param {String} authenticator_id - the ID of the authenticator
4441cb0ef41Sopenharmony_ci         * @param {Object} credential - A `Credential Parameters
4451cb0ef41Sopenharmony_ci         *                              <https://w3c.github.io/webauthn/#credential-parameters>`_
4461cb0ef41Sopenharmony_ci         *                              object
4471cb0ef41Sopenharmony_ci         * @param {WindowProxy} context - Browsing context in which
4481cb0ef41Sopenharmony_ci         *                                to run the call, or null for the current
4491cb0ef41Sopenharmony_ci         *                                browsing context.
4501cb0ef41Sopenharmony_ci         *
4511cb0ef41Sopenharmony_ci         * @returns {Promise} fulfilled after the credential is added, or
4521cb0ef41Sopenharmony_ci         *                    rejected in the cases the WebDriver command
4531cb0ef41Sopenharmony_ci         *                    errors
4541cb0ef41Sopenharmony_ci         */
4551cb0ef41Sopenharmony_ci        add_credential: function(authenticator_id, credential, context=null) {
4561cb0ef41Sopenharmony_ci            return window.test_driver_internal.add_credential(authenticator_id, credential, context);
4571cb0ef41Sopenharmony_ci        },
4581cb0ef41Sopenharmony_ci
4591cb0ef41Sopenharmony_ci        /**
4601cb0ef41Sopenharmony_ci         * Gets all the credentials stored in an authenticator
4611cb0ef41Sopenharmony_ci         *
4621cb0ef41Sopenharmony_ci         * This function retrieves all the credentials (added via the U2F API,
4631cb0ef41Sopenharmony_ci         * WebAuthn, or the add_credential function) stored in a virtual
4641cb0ef41Sopenharmony_ci         * authenticator
4651cb0ef41Sopenharmony_ci         *
4661cb0ef41Sopenharmony_ci         * Matches the `Get Credentials
4671cb0ef41Sopenharmony_ci         * <https://w3c.github.io/webauthn/#sctn-automation-get-credentials>`_
4681cb0ef41Sopenharmony_ci         * WebDriver command.
4691cb0ef41Sopenharmony_ci         *
4701cb0ef41Sopenharmony_ci         * @param {String} authenticator_id - the ID of the authenticator
4711cb0ef41Sopenharmony_ci         * @param {WindowProxy} context - Browsing context in which
4721cb0ef41Sopenharmony_ci         *                                to run the call, or null for the current
4731cb0ef41Sopenharmony_ci         *                                browsing context.
4741cb0ef41Sopenharmony_ci         *
4751cb0ef41Sopenharmony_ci         * @returns {Promise} fulfilled after the credentials are
4761cb0ef41Sopenharmony_ci         *                    returned, or rejected in the cases the
4771cb0ef41Sopenharmony_ci         *                    WebDriver command errors. Returns an
4781cb0ef41Sopenharmony_ci         *                    array of `Credential Parameters
4791cb0ef41Sopenharmony_ci         *                    <https://w3c.github.io/webauthn/#credential-parameters>`_
4801cb0ef41Sopenharmony_ci         */
4811cb0ef41Sopenharmony_ci        get_credentials: function(authenticator_id, context=null) {
4821cb0ef41Sopenharmony_ci            return window.test_driver_internal.get_credentials(authenticator_id, context=null);
4831cb0ef41Sopenharmony_ci        },
4841cb0ef41Sopenharmony_ci
4851cb0ef41Sopenharmony_ci        /**
4861cb0ef41Sopenharmony_ci         * Remove a credential stored in an authenticator
4871cb0ef41Sopenharmony_ci         *
4881cb0ef41Sopenharmony_ci         * Matches the `Remove Credential
4891cb0ef41Sopenharmony_ci         * <https://w3c.github.io/webauthn/#sctn-automation-remove-credential>`_
4901cb0ef41Sopenharmony_ci         * WebDriver command.
4911cb0ef41Sopenharmony_ci         *
4921cb0ef41Sopenharmony_ci         * @param {String} authenticator_id - the ID of the authenticator
4931cb0ef41Sopenharmony_ci         * @param {String} credential_id - the ID of the credential
4941cb0ef41Sopenharmony_ci         * @param {WindowProxy} context - Browsing context in which
4951cb0ef41Sopenharmony_ci         *                                to run the call, or null for the current
4961cb0ef41Sopenharmony_ci         *                                browsing context.
4971cb0ef41Sopenharmony_ci         *
4981cb0ef41Sopenharmony_ci         * @returns {Promise} fulfilled after the credential is removed, or
4991cb0ef41Sopenharmony_ci         *                    rejected in the cases the WebDriver command
5001cb0ef41Sopenharmony_ci         *                    errors.
5011cb0ef41Sopenharmony_ci         */
5021cb0ef41Sopenharmony_ci        remove_credential: function(authenticator_id, credential_id, context=null) {
5031cb0ef41Sopenharmony_ci            return window.test_driver_internal.remove_credential(authenticator_id, credential_id, context);
5041cb0ef41Sopenharmony_ci        },
5051cb0ef41Sopenharmony_ci
5061cb0ef41Sopenharmony_ci        /**
5071cb0ef41Sopenharmony_ci         * Removes all the credentials stored in a virtual authenticator
5081cb0ef41Sopenharmony_ci         *
5091cb0ef41Sopenharmony_ci         * Matches the `Remove All Credentials
5101cb0ef41Sopenharmony_ci         * <https://w3c.github.io/webauthn/#sctn-automation-remove-all-credentials>`_
5111cb0ef41Sopenharmony_ci         * WebDriver command.
5121cb0ef41Sopenharmony_ci         *
5131cb0ef41Sopenharmony_ci         * @param {String} authenticator_id - the ID of the authenticator
5141cb0ef41Sopenharmony_ci         * @param {WindowProxy} context - Browsing context in which
5151cb0ef41Sopenharmony_ci         *                                to run the call, or null for the current
5161cb0ef41Sopenharmony_ci         *                                browsing context.
5171cb0ef41Sopenharmony_ci         *
5181cb0ef41Sopenharmony_ci         * @returns {Promise} fulfilled after the credentials are removed, or
5191cb0ef41Sopenharmony_ci         *                    rejected in the cases the WebDriver command
5201cb0ef41Sopenharmony_ci         *                    errors.
5211cb0ef41Sopenharmony_ci         */
5221cb0ef41Sopenharmony_ci        remove_all_credentials: function(authenticator_id, context=null) {
5231cb0ef41Sopenharmony_ci            return window.test_driver_internal.remove_all_credentials(authenticator_id, context);
5241cb0ef41Sopenharmony_ci        },
5251cb0ef41Sopenharmony_ci
5261cb0ef41Sopenharmony_ci        /**
5271cb0ef41Sopenharmony_ci         * Sets the User Verified flag on an authenticator
5281cb0ef41Sopenharmony_ci         *
5291cb0ef41Sopenharmony_ci         * Sets whether requests requiring user verification will succeed or
5301cb0ef41Sopenharmony_ci         * fail on a given virtual authenticator
5311cb0ef41Sopenharmony_ci         *
5321cb0ef41Sopenharmony_ci         * Matches the `Set User Verified
5331cb0ef41Sopenharmony_ci         * <https://w3c.github.io/webauthn/#sctn-automation-set-user-verified>`_
5341cb0ef41Sopenharmony_ci         * WebDriver command.
5351cb0ef41Sopenharmony_ci         *
5361cb0ef41Sopenharmony_ci         * @param {String} authenticator_id - the ID of the authenticator
5371cb0ef41Sopenharmony_ci         * @param {boolean} uv - the User Verified flag
5381cb0ef41Sopenharmony_ci         * @param {WindowProxy} context - Browsing context in which
5391cb0ef41Sopenharmony_ci         *                                to run the call, or null for the current
5401cb0ef41Sopenharmony_ci         *                                browsing context.
5411cb0ef41Sopenharmony_ci         */
5421cb0ef41Sopenharmony_ci        set_user_verified: function(authenticator_id, uv, context=null) {
5431cb0ef41Sopenharmony_ci            return window.test_driver_internal.set_user_verified(authenticator_id, uv, context);
5441cb0ef41Sopenharmony_ci        },
5451cb0ef41Sopenharmony_ci
5461cb0ef41Sopenharmony_ci        /**
5471cb0ef41Sopenharmony_ci         * Sets the storage access rule for an origin when embedded
5481cb0ef41Sopenharmony_ci         * in a third-party context.
5491cb0ef41Sopenharmony_ci         *
5501cb0ef41Sopenharmony_ci         * Matches the `Set Storage Access
5511cb0ef41Sopenharmony_ci         * <https://privacycg.github.io/storage-access/#set-storage-access-command>`_
5521cb0ef41Sopenharmony_ci         * WebDriver command.
5531cb0ef41Sopenharmony_ci         *
5541cb0ef41Sopenharmony_ci         * @param {String} origin - A third-party origin to block or allow.
5551cb0ef41Sopenharmony_ci         *                          May be "*" to indicate all origins.
5561cb0ef41Sopenharmony_ci         * @param {String} embedding_origin - an embedding (first-party) origin
5571cb0ef41Sopenharmony_ci         *                                    on which {origin}'s access should
5581cb0ef41Sopenharmony_ci         *                                    be blocked or allowed.
5591cb0ef41Sopenharmony_ci         *                                    May be "*" to indicate all origins.
5601cb0ef41Sopenharmony_ci         * @param {String} state - The storage access setting.
5611cb0ef41Sopenharmony_ci         *                         Must be either "allowed" or "blocked".
5621cb0ef41Sopenharmony_ci         * @param {WindowProxy} context - Browsing context in which
5631cb0ef41Sopenharmony_ci         *                                to run the call, or null for the current
5641cb0ef41Sopenharmony_ci         *                                browsing context.
5651cb0ef41Sopenharmony_ci         *
5661cb0ef41Sopenharmony_ci         * @returns {Promise} Fulfilled after the storage access rule has been
5671cb0ef41Sopenharmony_ci         *                    set, or rejected if setting the rule fails.
5681cb0ef41Sopenharmony_ci         */
5691cb0ef41Sopenharmony_ci        set_storage_access: function(origin, embedding_origin, state, context=null) {
5701cb0ef41Sopenharmony_ci            if (state !== "allowed" && state !== "blocked") {
5711cb0ef41Sopenharmony_ci                throw new Error("storage access status must be 'allowed' or 'blocked'");
5721cb0ef41Sopenharmony_ci            }
5731cb0ef41Sopenharmony_ci            const blocked = state === "blocked";
5741cb0ef41Sopenharmony_ci            return window.test_driver_internal.set_storage_access(origin, embedding_origin, blocked, context);
5751cb0ef41Sopenharmony_ci        },
5761cb0ef41Sopenharmony_ci
5771cb0ef41Sopenharmony_ci        /**
5781cb0ef41Sopenharmony_ci         * Sets the current transaction automation mode for Secure Payment
5791cb0ef41Sopenharmony_ci         * Confirmation.
5801cb0ef41Sopenharmony_ci         *
5811cb0ef41Sopenharmony_ci         * This function places `Secure Payment
5821cb0ef41Sopenharmony_ci         * Confirmation <https://w3c.github.io/secure-payment-confirmation>`_ into
5831cb0ef41Sopenharmony_ci         * an automated 'autoaccept' or 'autoreject' mode, to allow testing
5841cb0ef41Sopenharmony_ci         * without user interaction with the transaction UX prompt.
5851cb0ef41Sopenharmony_ci         *
5861cb0ef41Sopenharmony_ci         * Matches the `Set SPC Transaction Mode
5871cb0ef41Sopenharmony_ci         * <https://w3c.github.io/secure-payment-confirmation/#sctn-automation-set-spc-transaction-mode>`_
5881cb0ef41Sopenharmony_ci         * WebDriver command.
5891cb0ef41Sopenharmony_ci         *
5901cb0ef41Sopenharmony_ci         * @example
5911cb0ef41Sopenharmony_ci         * await test_driver.set_spc_transaction_mode("autoaccept");
5921cb0ef41Sopenharmony_ci         * test.add_cleanup(() => {
5931cb0ef41Sopenharmony_ci         *   return test_driver.set_spc_transaction_mode("none");
5941cb0ef41Sopenharmony_ci         * });
5951cb0ef41Sopenharmony_ci         *
5961cb0ef41Sopenharmony_ci         * // Assumption: `request` is a PaymentRequest with a secure-payment-confirmation
5971cb0ef41Sopenharmony_ci         * // payment method.
5981cb0ef41Sopenharmony_ci         * const response = await request.show();
5991cb0ef41Sopenharmony_ci         *
6001cb0ef41Sopenharmony_ci         * @param {String} mode - The `transaction mode
6011cb0ef41Sopenharmony_ci         *                        <https://w3c.github.io/secure-payment-confirmation/#enumdef-transactionautomationmode>`_
6021cb0ef41Sopenharmony_ci         *                        to set. Must be one of "``none``",
6031cb0ef41Sopenharmony_ci         *                        "``autoaccept``", or
6041cb0ef41Sopenharmony_ci         *                        "``autoreject``".
6051cb0ef41Sopenharmony_ci         * @param {WindowProxy} context - Browsing context in which
6061cb0ef41Sopenharmony_ci         *                                to run the call, or null for the current
6071cb0ef41Sopenharmony_ci         *                                browsing context.
6081cb0ef41Sopenharmony_ci         *
6091cb0ef41Sopenharmony_ci         * @returns {Promise} Fulfilled after the transaction mode has been set,
6101cb0ef41Sopenharmony_ci         *                    or rejected if setting the mode fails.
6111cb0ef41Sopenharmony_ci         */
6121cb0ef41Sopenharmony_ci        set_spc_transaction_mode: function(mode, context=null) {
6131cb0ef41Sopenharmony_ci          return window.test_driver_internal.set_spc_transaction_mode(mode, context);
6141cb0ef41Sopenharmony_ci        },
6151cb0ef41Sopenharmony_ci    };
6161cb0ef41Sopenharmony_ci
6171cb0ef41Sopenharmony_ci    window.test_driver_internal = {
6181cb0ef41Sopenharmony_ci        /**
6191cb0ef41Sopenharmony_ci         * This flag should be set to `true` by any code which implements the
6201cb0ef41Sopenharmony_ci         * internal methods defined below for automation purposes. Doing so
6211cb0ef41Sopenharmony_ci         * allows the library to signal failure immediately when an automated
6221cb0ef41Sopenharmony_ci         * implementation of one of the methods is not available.
6231cb0ef41Sopenharmony_ci         */
6241cb0ef41Sopenharmony_ci        in_automation: false,
6251cb0ef41Sopenharmony_ci
6261cb0ef41Sopenharmony_ci        click: function(element, coords) {
6271cb0ef41Sopenharmony_ci            if (this.in_automation) {
6281cb0ef41Sopenharmony_ci                return Promise.reject(new Error('Not implemented'));
6291cb0ef41Sopenharmony_ci            }
6301cb0ef41Sopenharmony_ci
6311cb0ef41Sopenharmony_ci            return new Promise(function(resolve, reject) {
6321cb0ef41Sopenharmony_ci                element.addEventListener("click", resolve);
6331cb0ef41Sopenharmony_ci            });
6341cb0ef41Sopenharmony_ci        },
6351cb0ef41Sopenharmony_ci
6361cb0ef41Sopenharmony_ci        delete_all_cookies: function(context=null) {
6371cb0ef41Sopenharmony_ci            return Promise.reject(new Error("unimplemented"));
6381cb0ef41Sopenharmony_ci        },
6391cb0ef41Sopenharmony_ci
6401cb0ef41Sopenharmony_ci        send_keys: function(element, keys) {
6411cb0ef41Sopenharmony_ci            if (this.in_automation) {
6421cb0ef41Sopenharmony_ci                return Promise.reject(new Error('Not implemented'));
6431cb0ef41Sopenharmony_ci            }
6441cb0ef41Sopenharmony_ci
6451cb0ef41Sopenharmony_ci            return new Promise(function(resolve, reject) {
6461cb0ef41Sopenharmony_ci                var seen = "";
6471cb0ef41Sopenharmony_ci
6481cb0ef41Sopenharmony_ci                function remove() {
6491cb0ef41Sopenharmony_ci                    element.removeEventListener("keydown", onKeyDown);
6501cb0ef41Sopenharmony_ci                }
6511cb0ef41Sopenharmony_ci
6521cb0ef41Sopenharmony_ci                function onKeyDown(event) {
6531cb0ef41Sopenharmony_ci                    if (event.key.length > 1) {
6541cb0ef41Sopenharmony_ci                        return;
6551cb0ef41Sopenharmony_ci                    }
6561cb0ef41Sopenharmony_ci
6571cb0ef41Sopenharmony_ci                    seen += event.key;
6581cb0ef41Sopenharmony_ci
6591cb0ef41Sopenharmony_ci                    if (keys.indexOf(seen) !== 0) {
6601cb0ef41Sopenharmony_ci                        reject(new Error("Unexpected key sequence: " + seen));
6611cb0ef41Sopenharmony_ci                        remove();
6621cb0ef41Sopenharmony_ci                    } else if (seen === keys) {
6631cb0ef41Sopenharmony_ci                        resolve();
6641cb0ef41Sopenharmony_ci                        remove();
6651cb0ef41Sopenharmony_ci                    }
6661cb0ef41Sopenharmony_ci                }
6671cb0ef41Sopenharmony_ci
6681cb0ef41Sopenharmony_ci                element.addEventListener("keydown", onKeyDown);
6691cb0ef41Sopenharmony_ci            });
6701cb0ef41Sopenharmony_ci        },
6711cb0ef41Sopenharmony_ci
6721cb0ef41Sopenharmony_ci        freeze: function(context=null) {
6731cb0ef41Sopenharmony_ci            return Promise.reject(new Error("unimplemented"));
6741cb0ef41Sopenharmony_ci        },
6751cb0ef41Sopenharmony_ci
6761cb0ef41Sopenharmony_ci        minimize_window: function(context=null) {
6771cb0ef41Sopenharmony_ci            return Promise.reject(new Error("unimplemented"));
6781cb0ef41Sopenharmony_ci        },
6791cb0ef41Sopenharmony_ci
6801cb0ef41Sopenharmony_ci        set_window_rect: function(rect, context=null) {
6811cb0ef41Sopenharmony_ci            return Promise.reject(new Error("unimplemented"));
6821cb0ef41Sopenharmony_ci        },
6831cb0ef41Sopenharmony_ci
6841cb0ef41Sopenharmony_ci        action_sequence: function(actions, context=null) {
6851cb0ef41Sopenharmony_ci            return Promise.reject(new Error("unimplemented"));
6861cb0ef41Sopenharmony_ci        },
6871cb0ef41Sopenharmony_ci
6881cb0ef41Sopenharmony_ci        generate_test_report: function(message, context=null) {
6891cb0ef41Sopenharmony_ci            return Promise.reject(new Error("unimplemented"));
6901cb0ef41Sopenharmony_ci        },
6911cb0ef41Sopenharmony_ci
6921cb0ef41Sopenharmony_ci
6931cb0ef41Sopenharmony_ci        set_permission: function(permission_params, context=null) {
6941cb0ef41Sopenharmony_ci            return Promise.reject(new Error("unimplemented"));
6951cb0ef41Sopenharmony_ci        },
6961cb0ef41Sopenharmony_ci
6971cb0ef41Sopenharmony_ci        add_virtual_authenticator: function(config, context=null) {
6981cb0ef41Sopenharmony_ci            return Promise.reject(new Error("unimplemented"));
6991cb0ef41Sopenharmony_ci        },
7001cb0ef41Sopenharmony_ci
7011cb0ef41Sopenharmony_ci        remove_virtual_authenticator: function(authenticator_id, context=null) {
7021cb0ef41Sopenharmony_ci            return Promise.reject(new Error("unimplemented"));
7031cb0ef41Sopenharmony_ci        },
7041cb0ef41Sopenharmony_ci
7051cb0ef41Sopenharmony_ci        add_credential: function(authenticator_id, credential, context=null) {
7061cb0ef41Sopenharmony_ci            return Promise.reject(new Error("unimplemented"));
7071cb0ef41Sopenharmony_ci        },
7081cb0ef41Sopenharmony_ci
7091cb0ef41Sopenharmony_ci        get_credentials: function(authenticator_id, context=null) {
7101cb0ef41Sopenharmony_ci            return Promise.reject(new Error("unimplemented"));
7111cb0ef41Sopenharmony_ci        },
7121cb0ef41Sopenharmony_ci
7131cb0ef41Sopenharmony_ci        remove_credential: function(authenticator_id, credential_id, context=null) {
7141cb0ef41Sopenharmony_ci            return Promise.reject(new Error("unimplemented"));
7151cb0ef41Sopenharmony_ci        },
7161cb0ef41Sopenharmony_ci
7171cb0ef41Sopenharmony_ci        remove_all_credentials: function(authenticator_id, context=null) {
7181cb0ef41Sopenharmony_ci            return Promise.reject(new Error("unimplemented"));
7191cb0ef41Sopenharmony_ci        },
7201cb0ef41Sopenharmony_ci
7211cb0ef41Sopenharmony_ci        set_user_verified: function(authenticator_id, uv, context=null) {
7221cb0ef41Sopenharmony_ci            return Promise.reject(new Error("unimplemented"));
7231cb0ef41Sopenharmony_ci        },
7241cb0ef41Sopenharmony_ci
7251cb0ef41Sopenharmony_ci        set_storage_access: function(origin, embedding_origin, blocked, context=null) {
7261cb0ef41Sopenharmony_ci            return Promise.reject(new Error("unimplemented"));
7271cb0ef41Sopenharmony_ci        },
7281cb0ef41Sopenharmony_ci
7291cb0ef41Sopenharmony_ci        set_spc_transaction_mode: function(mode, context=null) {
7301cb0ef41Sopenharmony_ci            return Promise.reject(new Error("unimplemented"));
7311cb0ef41Sopenharmony_ci        },
7321cb0ef41Sopenharmony_ci
7331cb0ef41Sopenharmony_ci    };
7341cb0ef41Sopenharmony_ci})();
735