mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-03-16 18:20:51 +00:00
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:
parent
0d3f877ec4
commit
ba98491fc1
44
crates/web-sys/tests/all/history.rs
Normal file
44
crates/web-sys/tests/all/history.rs
Normal 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();
|
||||
}
|
@ -5,6 +5,7 @@ mod event;
|
||||
mod headers;
|
||||
mod response;
|
||||
mod element;
|
||||
mod history;
|
||||
|
||||
fn websys_project() -> Project {
|
||||
project()
|
||||
|
Loading…
x
Reference in New Issue
Block a user