diff options
Diffstat (limited to 'src/html/env.nim')
-rw-r--r-- | src/html/env.nim | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/html/env.nim b/src/html/env.nim new file mode 100644 index 00000000..6db018c9 --- /dev/null +++ b/src/html/env.nim @@ -0,0 +1,26 @@ +import html/dom +import html/htmlparser +import io/loader +import js/javascript +import types/url + +proc newWindow*(scripting: bool, loader = none(FileLoader)): Window = + result = Window( + loader: loader, + settings: EnvironmentSettings( + scripting: scripting + ) + ) + if scripting: + let rt = newJSRuntime() + let ctx = rt.newJSContext() + result.jsrt = rt + result.jsctx = ctx + var global = JS_GetGlobalObject(ctx) + ctx.registerType(Window, asglobal = true) + ctx.setOpaque(global, result) + ctx.setProperty(global, "window", global) + JS_FreeValue(ctx, global) + ctx.addDOMModule() + ctx.addURLModule() + ctx.addHTMLModule() |