Enable History Web API (#561)

* Add Number.isNaN() binding

* Add binding for Math.hypot()

* Implement Math.min() and Math.max() bindings

* Enable History API
This commit is contained in:
Tyler Wilcock 2018-07-26 12:21:04 -05:00 committed by Alex Crichton
parent 0d3f877ec4
commit ba98491fc1
3 changed files with 45 additions and 0 deletions

View File

@ -0,0 +1,44 @@
use super::websys_project;
#[test]
fn history() {
websys_project()
.file(
"src/lib.rs",
r#"
#![feature(use_extern_macros)]
extern crate wasm_bindgen;
use wasm_bindgen::prelude::*;
extern crate web_sys;
#[wasm_bindgen]
pub fn test_history(history: &web_sys::History) {
assert_eq!(history.length().unwrap(), 2);
assert!(history.go(1).is_ok());
assert!(history.back().is_ok());
assert!(history.forward().is_ok());
assert!(history.go(-1).is_ok());
history.set_scroll_restoration(web_sys::ScrollRestoration::Manual).expect("failure to set scroll restoration");
assert_eq!(history.scroll_restoration().unwrap(), web_sys::ScrollRestoration::Manual);
history.set_scroll_restoration(web_sys::ScrollRestoration::Auto).expect("failure to set scroll restoration");
assert_eq!(history.scroll_restoration().unwrap(), web_sys::ScrollRestoration::Auto);
}
"#,
)
.file(
"test.js",
r#"
import * as assert from "assert";
import * as wasm from "./out";
export function test() {
window.history.pushState({}, "I am a title", "part/of/some/url");
wasm.test_history(window.history);
}
"#,
)
.test();
}

View File

@ -5,6 +5,7 @@ mod event;
mod headers;
mod response;
mod element;
mod history;
fn websys_project() -> Project {
project()