Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into reexporting_in_2018
- Loading branch information
Showing
29 changed files
with
260 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
use wasm_bindgen::prelude::*; | ||
|
||
#[wasm_bindgen(typescript_custom_section)] | ||
const TS_INTERFACE_EXPORT: &'static str = r" | ||
interface Height { height: number; } | ||
"; | ||
|
||
#[wasm_bindgen] | ||
pub struct Person { | ||
pub height: u32, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import * as wbg from '../pkg/typescript_tests'; | ||
|
||
const height: wbg.Height = new wbg.Person(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,4 @@ | ||
use wasm_bindgen::prelude::*; | ||
|
||
#[wasm_bindgen] | ||
pub fn greet(_: &str) {} | ||
|
||
#[wasm_bindgen] | ||
struct A { | ||
} | ||
|
||
#[wasm_bindgen] | ||
impl A { | ||
#[wasm_bindgen(constructor)] | ||
pub fn new() -> A { | ||
A {} | ||
} | ||
|
||
pub fn other() {} | ||
|
||
pub fn foo(&self) {} | ||
} | ||
mod custom_section; | ||
mod opt_args_and_ret; | ||
mod simple_fn; | ||
mod simple_struct; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import * as wasm from '../pkg/typescript_tests_bg'; | ||
|
||
const memory: WebAssembly.Memory = wasm.memory; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
use wasm_bindgen::prelude::*; | ||
|
||
#[wasm_bindgen] | ||
pub fn opt_fn(_a: Option<i32>) -> Option<i32> { | ||
None | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import * as wbg from '../pkg/typescript_tests'; | ||
|
||
const opt_fn: (a: number | undefined) => number | undefined = wbg.opt_fn; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
use wasm_bindgen::prelude::*; | ||
|
||
#[wasm_bindgen] | ||
pub fn greet(_: &str) {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import * as wbg from '../pkg/typescript_tests'; | ||
import * as wasm from '../pkg/typescript_tests_bg'; | ||
|
||
const wbg_greet: (a: string) => void = wbg.greet; | ||
const wasm_greet: (a: number, b: number) => void = wasm.greet; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
use wasm_bindgen::prelude::*; | ||
|
||
#[wasm_bindgen] | ||
pub struct A { | ||
} | ||
|
||
#[wasm_bindgen] | ||
impl A { | ||
#[wasm_bindgen(constructor)] | ||
pub fn new() -> A { | ||
A {} | ||
} | ||
|
||
pub fn other() {} | ||
|
||
pub fn foo(&self) {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import * as wbg from '../pkg/typescript_tests'; | ||
|
||
const a = new wbg.A(); | ||
wbg.A.other(); | ||
a.foo(); | ||
a.free(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,6 @@ | |
"baseUrl": "." | ||
}, | ||
"include": [ | ||
"index.ts" | ||
"src/*.ts" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
92 changes: 92 additions & 0 deletions
92
crates/web-sys/tests/wasm/rtc_rtp_transceiver_direction.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
use wasm_bindgen::{prelude::*, JsCast}; | ||
use wasm_bindgen_futures::JsFuture; | ||
use wasm_bindgen_test::*; | ||
|
||
use futures::{ | ||
future::{ok, IntoFuture}, | ||
Future, | ||
}; | ||
|
||
use web_sys::{ | ||
RtcPeerConnection, RtcRtpTransceiver, RtcRtpTransceiverDirection, RtcRtpTransceiverInit, | ||
RtcSessionDescriptionInit, | ||
}; | ||
|
||
#[wasm_bindgen( | ||
inline_js = "export function is_unified_avail() { return Object.keys(RTCRtpTransceiver.prototype).indexOf('currentDirection')>-1; }" | ||
)] | ||
extern "C" { | ||
/// Available in FF since forever, in Chrome since 72, in Safari since 12.1 | ||
fn is_unified_avail() -> bool; | ||
} | ||
|
||
#[wasm_bindgen_test(async)] | ||
fn rtc_rtp_transceiver_direction() -> Box<dyn Future<Item = (), Error = JsValue>> { | ||
if !is_unified_avail() { | ||
return Box::new(Ok(()).into_future()); | ||
} | ||
|
||
let mut tr_init: RtcRtpTransceiverInit = RtcRtpTransceiverInit::new(); | ||
|
||
let pc1: RtcPeerConnection = RtcPeerConnection::new().unwrap(); | ||
|
||
let tr1: RtcRtpTransceiver = pc1.add_transceiver_with_str_and_init( | ||
"audio", | ||
tr_init.direction(RtcRtpTransceiverDirection::Sendonly), | ||
); | ||
assert_eq!(tr1.direction(), RtcRtpTransceiverDirection::Sendonly); | ||
assert_eq!(tr1.current_direction(), None); | ||
|
||
let pc2: RtcPeerConnection = RtcPeerConnection::new().unwrap(); | ||
|
||
let r = exchange_sdps(pc1, pc2).and_then(move |(_, p2)| { | ||
assert_eq!(tr1.direction(), RtcRtpTransceiverDirection::Sendonly); | ||
assert_eq!( | ||
tr1.current_direction(), | ||
Some(RtcRtpTransceiverDirection::Sendonly) | ||
); | ||
|
||
let tr2: RtcRtpTransceiver = js_sys::try_iter(&p2.get_transceivers()) | ||
.unwrap() | ||
.unwrap() | ||
.next() | ||
.unwrap() | ||
.unwrap() | ||
.unchecked_into(); | ||
|
||
assert_eq!(tr2.direction(), RtcRtpTransceiverDirection::Recvonly); | ||
assert_eq!( | ||
tr2.current_direction(), | ||
Some(RtcRtpTransceiverDirection::Recvonly) | ||
); | ||
|
||
Ok(()) | ||
}); | ||
|
||
Box::new(r) | ||
} | ||
|
||
fn exchange_sdps( | ||
p1: RtcPeerConnection, | ||
p2: RtcPeerConnection, | ||
) -> impl Future<Item = (RtcPeerConnection, RtcPeerConnection), Error = JsValue> { | ||
JsFuture::from(p1.create_offer()) | ||
.and_then(move |offer| { | ||
let offer = offer.unchecked_into::<RtcSessionDescriptionInit>(); | ||
JsFuture::from(p1.set_local_description(&offer)).join4( | ||
JsFuture::from(p2.set_remote_description(&offer)), | ||
Ok(p1), | ||
Ok(p2), | ||
) | ||
}) | ||
.and_then(|(_, _, p1, p2)| JsFuture::from(p2.create_answer()).join3(Ok(p1), Ok(p2))) | ||
.and_then(|(answer, p1, p2)| { | ||
let answer = answer.unchecked_into::<RtcSessionDescriptionInit>(); | ||
JsFuture::from(p2.set_local_description(&answer)).join4( | ||
JsFuture::from(p1.set_remote_description(&answer)), | ||
Ok(p1), | ||
Ok(p2), | ||
) | ||
}) | ||
.and_then(|(_, _, p1, p2)| Ok((p1, p2))) | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.