• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2022 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16if (!globalThis.$262) {
17    globalThis.$262 = {
18        global: globalThis,
19        evalScript(code) {
20            try {
21                global.evalScript(code);
22                return { type: 'normal', value: undefined };
23            } catch (e) {
24                return { type: 'throw', value: e };
25            }
26        },
27        gc() {
28            throw new Test262Error('gc() not yet supported.');
29        },
30        getGlobal(name) {
31            return global[name];
32        },
33        setGlobal(name, value) {
34            global[name] = value;
35        },
36        agent: (function () {
37            function thrower() {
38                throw new Test262Error('agent.* not yet supported.');
39            };
40            return {
41                start: thrower,
42                broadcast: thrower,
43                getReport: thrower,
44                sleep: thrower,
45                monotonicNow: thrower,
46            };
47        })(),
48    };
49}
50
51$262.IsHTMLDDA = function () { };
52$262.destroy = function () { };
53$262.getGlobal = function (name) {
54    return this.global[name];
55};
56$262.setGlobal = function (name, value) {
57    this.global[name] = value;
58};
59$262.source = $SOURCE;
60