For AI agents: the complete documentation index is available at /next/zh/llms.txt, the full documentation bundle is available at /next/zh/llms-full.txt, and this page is available as Markdown at /next/zh/api/lynx-testing-environment/Class.LynxTestingEnv.md.
Lynx
  • 简体中文
  • lynx-testing-environment / LynxTestingEnv

    LynxTestingEnv

    A pure-JavaScript implementation of the Lynx Spec, notably the Element PAPI and Dual-threaded Model for use with Node.js.

    示例

    import { LynxTestingEnv } from '@lynx-js/testing-environment';
    import { JSDOM } from 'jsdom';
    
    const lynxTestingEnv = new LynxTestingEnv({ window: new JSDOM().window });
    
    lynxTestingEnv.switchToMainThread();
    // use the main thread Element PAPI
    const page = __CreatePage('0', 0);
    const view = __CreateView(0);
    __AppendElement(page, view);
    

    构造函数

    new LynxTestingEnv()

    new LynxTestingEnv(env?: LynxEnv): LynxTestingEnv

    参数

    范围类型
    env?LynxEnv

    返回

    LynxTestingEnv

    定义于

    index.d.ts:166

    属性

    backgroundThread

    backgroundThread: LynxGlobalThis;

    The global object for the background thread.

    示例

    import { LynxTestingEnv } from '@lynx-js/testing-environment';
    import { JSDOM } from 'jsdom';
    
    const lynxTestingEnv = new LynxTestingEnv({ window: new JSDOM().window });
    
    lynxTestingEnv.switchToBackgroundThread();
    // use the background thread global object
    globalThis.lynxCoreInject.tt.OnLifecycleEvent(...args);

    定义于

    index.d.ts:145


    env

    env: LynxEnv;

    定义于

    index.d.ts:165


    mainThread

    mainThread: LynxGlobalThis & ElementTreeGlobals;

    The global object for the main thread.

    示例

    import { LynxTestingEnv } from '@lynx-js/testing-environment';
    import { JSDOM } from 'jsdom';
    
    const lynxTestingEnv = new LynxTestingEnv({ window: new JSDOM().window });
    
    lynxTestingEnv.switchToMainThread();
    // use the main thread global object
    const page = globalThis.__CreatePage('0', 0);
    const view = globalThis.__CreateView(0);
    globalThis.__AppendElement(page, view);

    定义于

    index.d.ts:164

    方法

    clearGlobal()

    clearGlobal(): void

    返回

    void

    定义于

    index.d.ts:170


    injectGlobals()

    injectGlobals(): void

    返回

    void

    定义于

    index.d.ts:167


    reset()

    reset(): void

    返回

    void

    定义于

    index.d.ts:171


    switchToBackgroundThread()

    switchToBackgroundThread(): void

    返回

    void

    定义于

    index.d.ts:168


    switchToMainThread()

    switchToMainThread(): void

    返回

    void

    定义于

    index.d.ts:169

    除非另有说明,本项目采用知识共享署名 4.0 国际许可协议进行许可,代码示例采用 Apache License 2.0 许可协议进行许可。