Skip to content

Commit 5088ff0

Browse files
committed
Fix webidl-tests fallout
1 parent 611e418 commit 5088ff0

File tree

4 files changed

+32
-10
lines changed

4 files changed

+32
-10
lines changed

crates/webidl-tests/global.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
global.global_no_args = () => 3;
2-
global.global_with_args = (a, b) => a + b;
3-
global.global_attribute = 'x';
1+
const map = {
2+
global_no_args: () => 3,
3+
global_with_args: (a, b) => a + b,
4+
global_attribute: 'x',
5+
};
6+
7+
global.get_global = () => map;
48

crates/webidl-tests/global.rs

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,20 @@
11
use js_sys::Object;
2+
use wasm_bindgen::prelude::*;
23
use wasm_bindgen_test::*;
34

45
include!(concat!(env!("OUT_DIR"), "/global.rs"));
56

7+
#[wasm_bindgen]
8+
extern {
9+
fn get_global() -> Global;
10+
}
11+
612
#[wasm_bindgen_test]
713
fn works() {
8-
assert_eq!(Global::global_no_args(), 3);
9-
assert_eq!(Global::global_with_args("a", "b"), "ab");
10-
assert_eq!(Global::global_attribute(), "x");
11-
Global::set_global_attribute("y");
12-
assert_eq!(Global::global_attribute(), "y");
14+
let x = get_global();
15+
assert_eq!(x.global_no_args(), 3);
16+
assert_eq!(x.global_with_args("a", "b"), "ab");
17+
assert_eq!(x.global_attribute(), "x");
18+
x.set_global_attribute("y");
19+
assert_eq!(x.global_attribute(), "y");
1320
}

crates/webidl-tests/simple.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,11 @@ global.Unforgeable = class Unforgeable {
8787
}
8888
};
8989

90-
global.m = () => 123;
90+
global.GlobalMethod = class {
91+
m() { return 123; }
92+
};
93+
94+
global.get_global_method = () => new GlobalMethod();
9195

9296
global.Indexing = function () {
9397
return new Proxy({}, {

crates/webidl-tests/simple.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,16 @@ fn nullable_method() {
7272
assert!(f.opt(None) == None);
7373
}
7474

75+
#[wasm_bindgen]
76+
extern {
77+
fn get_global_method() -> GlobalMethod;
78+
}
79+
80+
7581
#[wasm_bindgen_test]
7682
fn global_method() {
77-
assert_eq!(GlobalMethod::m(), 123);
83+
let x = get_global_method();
84+
assert_eq!(x.m(), 123);
7885
}
7986

8087
#[wasm_bindgen_test]

0 commit comments

Comments
 (0)