-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathmain.rs
43 lines (32 loc) · 1.1 KB
/
main.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#![feature(const_fn)]
#![feature(const_ptr_null)]
#![allow(dead_code)]
#![deny(unsafe_code)]
extern crate env_logger;
extern crate mozjs as js;
extern crate libc;
#[macro_use] extern crate josephine;
#[macro_use] extern crate log;
mod fake_codegen;
mod minidom;
use josephine::JSContext;
use josephine::JSLifetime;
use minidom::Window;
fn main() {
let _ = env_logger::init();
debug!("Creating JSContext.");
let ref mut cx = JSContext::new().expect("Failed to build JSContext");
debug!("Creating global.");
let ref mut root = cx.new_root();
let window = Window::new(cx).in_root(root);
debug!("Entering compartment.");
let ref mut cx = cx.enter_unknown_compartment(window.0);
debug!("Printing hello");
cx.evaluate("console.log('Hello World. 😃')").unwrap();
debug!("Printing body");
cx.evaluate("console.log(document.body.tagName)").unwrap();
debug!("Done.");
}