简体   繁体   中英

How to introduce window and document objects into spidermonkey javascript shell?

I'm trying to build automated script testing engine using spidermonkey.

Some of the scripts I intend to test are using window and document objects, which are not defined in the js shell.

Is there an easy-track way to define window and document objects to be used in spidermonkey tests?

The SpiderMonkey shell just implements the JavaScript language with a few built-in-functions to do extended things like read files from the local filesystem into strings. When you build Mozilla there is an artifact called the XPCShell that may be used to access a more full browser environment, but I'm not sure if there is good documentation on how to use it properly. Your web search is as good as mine there!

Alternatively, there is the dom.js project which attempts to implement the HTML DOM in pure JavaScript. You may be able to load that project's JS in and program against its implementation of the Window and Document objects in the DOM.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM