Best headless browser for AI agents. Lite, Fast, High-Compatibility. Built in Rust
Rust ai-agentsai-toolsbrowserbrowser-automationcloud-browserheadlessheadless-browserkitesurfplaywrightpuppeteerrustservoweb-crawlerweb-crawlingweb-scraperweb-scraping
refactor(webrtc): derive constructor dictionaries without copying V8 strings
ldm026b9eab923db
diff --git a/moli-renderer-v8/src/context_bootstrap/assets/constructor_templates.rs b/moli-renderer-v8/src/context_bootstrap/assets/constructor_templates.rsindex a085c9821..6a955d420 100644--- a/moli-renderer-v8/src/context_bootstrap/assets/constructor_templates.rs+++ b/moli-renderer-v8/src/context_bootstrap/assets/constructor_templates.rs@@ -653,7 +653,7 @@ pub(in crate::context_bootstrap) fn build_constructor_template<'s>(web_api_interfaces::RTCSessionDescription,rtc_session_description_constructor_callback))- .length(1)+ .length(0).build(scope)}ConstructorKind::RtcPeerConnectionIceEvent => {diff --git a/moli-renderer-v8/src/context_bootstrap/webrtc.rs b/moli-renderer-v8/src/context_bootstrap/webrtc.rsindex 51b189057..54629c3cf 100644--- a/moli-renderer-v8/src/context_bootstrap/webrtc.rs+++ b/moli-renderer-v8/src/context_bootstrap/webrtc.rs@@ -6,6 +6,7 @@ use crate::web_api_interfaces;use moli_webapi_declare::{WebApiFunctionTemplate, WebApiObject};mod configuration;+mod dictionary_string;mod events;mod ice_candidate;mod ice_candidate_parser;@@ -126,7 +127,7 @@ struct RtcDataChannelObjectDeclaration<'scope> {#[webapi(plain)]struct RtcSessionDescriptionInitDeclaration<'scope> {#[webapi(data_property, enumerable)]- r#type: v8::Local<'scope, v8::String>,+ r#type: v8::Local<'scope, v8::Value>,#[webapi(data_property, enumerable)]sdp: v8::Local<'scope, v8::String>,}@@ -352,7 +353,7 @@ fn rtc_peer_connection_create_offer_callback<'s>(rv.set_undefined();return;};- let offer = RtcSessionDescriptionInitDeclaration::new(v8str(scope, "offer"), sdp)+ let offer = RtcSessionDescriptionInitDeclaration::new(v8str(scope, "offer").into(), sdp).bind(scope).expect("RTC offer declaration should bind");set_resolved_promise(scope, &mut rv, offer.into());diff --git a/moli-renderer-v8/src/context_bootstrap/webrtc/dictionary_string.rs b/moli-renderer-v8/src/context_bootstrap/webrtc/dictionary_string.rsnew file mode 100644index 000000000..ac10bb1e2--- /dev/null+++ b/moli-renderer-v8/src/context_bootstrap/webrtc/dictionary_string.rs@@ -0,0 +1,32 @@+use crate::{util::v8str, webidl};++// Missing defaulted DOMStrings need no allocation during conversion. Supplied+// strings retain their V8 handles, including lone UTF-16 surrogates, instead of+// copying SDP and candidate text through Rust strings and back into V8.+#[derive(Default)]+pub(super) struct DictionaryDomString<'s>(Option<v8::Local<'s, v8::String>>);++impl<'s> DictionaryDomString<'s> {+ pub(super) fn into_value(self, scope: &mut v8::PinScope<'s, '_>) -> v8::Local<'s, v8::String> {+ self.0.unwrap_or_else(|| v8str(scope, ""))+ }+}++impl<'s> webidl::WebIdlConverter<'s> for DictionaryDomString<'s> {+ type Options = ();++ fn convert(+ scope: &mut v8::PinScope<'s, '_>,+ value: v8::Local<'s, v8::Value>,+ context: webidl::Context,+ _: &(),+ ) -> Result<Self, webidl::WebIdlError> {+ if value.is_symbol() {+ return Err(webidl::WebIdlError::cannot_convert(context, "DOMString"));+ }+ value+ .to_string(scope)+ .map(|value| Self(Some(value)))+ .ok_or_else(|| webidl::WebIdlError::pending_exception(context))+ }+}diff --git a/moli-renderer-v8/src/context_bootstrap/webrtc/ice_candidate.rs b/moli-renderer-v8/src/context_bootstrap/webrtc/ice_candidate.rsindex d1272160b..3bc532c60 100644--- a/moli-renderer-v8/src/context_bootstrap/webrtc/ice_candidate.rs+++ b/moli-renderer-v8/src/context_bootstrap/webrtc/ice_candidate.rs@@ -1,14 +1,53 @@-use super::ice_candidate_parser::parse_ice_candidate;+use super::{dictionary_string::DictionaryDomString, ice_candidate_parser::parse_ice_candidate};use crate::web_api_interfaces;use crate::{util::{apply_webidl_constructor_prototype_fallback, callback_data_index_value, get_private_value,throw_type_error, v8str,},- webidl::{self, WebIdlConverter},+ webidl,};use moli_webapi_declare::{WebApiFunctionTemplate, WebApiObject};+#[derive(webidl::WebIdlDictionary)]+#[webidl(prefix = "RTCIceCandidateInit")]+struct CandidateInit<'s> {+ #[webidl(converter = "raw", default = DictionaryDomString::default())]+ candidate: DictionaryDomString<'s>,+ #[webidl(nullable)]+ sdp_m_line_index: Option<u16>,+ #[webidl(nullable, converter = "raw")]+ sdp_mid: Option<DictionaryDomString<'s>>,+ #[webidl(nullable, converter = "raw")]+ username_fragment: Option<DictionaryDomString<'s>>,+}++#[derive(Clone, Copy, webidl::WebIdlEnum)]+#[webidl(name = "RTCIceServerTransportProtocol", rename_all = "kebab-case")]+enum IceServerTransportProtocol {+ Udp,+ Tcp,+ Tls,+}++#[derive(webidl::WebIdlDictionary)]+#[webidl(prefix = "RTCLocalIceCandidateInit")]+struct LocalCandidateInit<'s> {+ #[webidl(inherit)]+ base: CandidateInit<'s>,+ #[webidl(nullable, converter = "enum")]+ relay_protocol: Option<IceServerTransportProtocol>,+ #[webidl(nullable, converter = "usv_string")]+ url: Option<String>,+}++#[derive(webidl::WebIdlArgs)]+#[webidl(prefix = "RTCIceCandidate")]+struct CandidateArgs<'s> {+ #[webidl(dictionary)]+ init: LocalCandidateInit<'s>,+}+const CANDIDATE_VALUES_SLOT: &str = "__moliRtcIceCandidateValues";#[derive(WebApiObject)]@@ -85,19 +124,27 @@ pub(in crate::context_bootstrap) fn rtc_ice_candidate_constructor_callback<'s>(throw_type_error(scope, "RTCIceCandidate constructor requires 'new'.");return;}- let dictionary = match webidl::dictionary_value(- args.get(0),- webidl::Context::argument("RTCIceCandidate", 1),- ) {- Ok(dictionary) => dictionary,- Err(error) => {- webidl::throw_error(scope, &error);- return;- }- };- let Some(mut values) = parse_candidate_init(scope, dictionary) else {+ let Some(parsed_args) = webidl::parse_args::<CandidateArgs>(scope, &args) else {return;};+ let init = parsed_args.init;+ let mut values: [v8::Local<'s, v8::Value>; 16] = [v8::null(scope).into(); 16];+ values[0] = init.base.candidate.into_value(scope).into();+ if let Some(mid) = init.base.sdp_mid {+ values[1] = mid.into_value(scope).into();+ }+ if let Some(line) = init.base.sdp_m_line_index {+ values[2] = v8::Integer::new_from_unsigned(scope, line.into()).into();+ }+ if let Some(fragment) = init.base.username_fragment {+ values[13] = fragment.into_value(scope).into();+ }+ if let Some(protocol) = init.relay_protocol {+ values[14] = v8str(scope, webidl::WebIdlEnumSnapshot::snapshot_token(&protocol)).into();+ }+ if let Some(url) = init.url {+ values[15] = v8::String::new(scope, &url).expect("ICE URL").into();+ }if values[1].is_null() && values[2].is_null() {throw_type_error(scope, "RTCIceCandidate requires sdpMid or sdpMLineIndex.");return;@@ -139,69 +186,6 @@ pub(in crate::context_bootstrap) fn rtc_ice_candidate_constructor_callback<'s>(rv.set(args.this().into());}-fn parse_candidate_init<'s>(- scope: &mut v8::PinScope<'s, '_>,- dictionary: Option<v8::Local<'s, v8::Object>>,-) -> Option<[v8::Local<'s, v8::Value>; 16]> {- let mut values = [v8::null(scope).into(); 16];- values[0] = v8str(scope, "").into();- let Some(dictionary) = dictionary else {- return Some(values);- };- // Convert base dictionary members in lexical order before derived members.- // Keep DOMStrings in V8, preserving lone UTF-16 surrogates; only `url` is a USVString.- for (name, index) in [- ("candidate", 0),- ("sdpMLineIndex", 2),- ("sdpMid", 1),- ("usernameFragment", 13),- ("relayProtocol", 14),- ("url", 15),- ] {- let raw = dictionary.get(scope, v8str(scope, name).into())?;- if raw.is_undefined() || (index != 0 && raw.is_null()) {- continue;- }- let context = webidl::Context::member("RTCLocalIceCandidateInit", name);- if index == 2 {- let value = match webidl::UnsignedShort::convert(scope, raw, context, &()) {- Ok(value) => value.0,- Err(error) => {- webidl::throw_error(scope, &error);- return None;- }- };- values[index] = v8::Integer::new_from_unsigned(scope, value.into()).into();- } else if index == 15 {- let value = match webidl::UsvString::convert(scope, raw, context, &Default::default()) {- Ok(value) => value.0,- Err(error) => {- webidl::throw_error(scope, &error);- return None;- }- };- values[index] = v8::String::new(scope, &value)?.into();- } else {- if raw.is_symbol() {- throw_type_error(scope, "Cannot convert a Symbol to a DOMString.");- return None;- }- let value = raw.to_string(scope)?;- if index == 14- && !matches!(- value.to_rust_string_lossy(scope).as_str(),- "udp" | "tcp" | "tls"- )- {- throw_type_error(scope, "Invalid RTCIceServerTransportProtocol.");- return None;- }- values[index] = value.into();- }- }- Some(values)-}-fn candidate_values<'s>(scope: &mut v8::PinScope<'s, '_>,receiver: v8::Local<'s, v8::Object>,diff --git a/moli-renderer-v8/src/context_bootstrap/webrtc/session_description.rs b/moli-renderer-v8/src/context_bootstrap/webrtc/session_description.rsindex f3c046e0d..aaf5999e0 100644--- a/moli-renderer-v8/src/context_bootstrap/webrtc/session_description.rs+++ b/moli-renderer-v8/src/context_bootstrap/webrtc/session_description.rs@@ -1,4 +1,4 @@-use super::RtcSessionDescriptionInitDeclaration;+use super::{RtcSessionDescriptionInitDeclaration, dictionary_string::DictionaryDomString};use crate::web_api_interfaces;use crate::{util::{@@ -13,11 +13,38 @@ const DESCRIPTION_TYPE_SLOT: &str = "__moliRtcSessionDescriptionType";const DESCRIPTION_SDP_SLOT: &str = "__moliRtcSessionDescriptionSdp";const DESCRIPTION_SLOTS: &[&str] = &[DESCRIPTION_TYPE_SLOT, DESCRIPTION_SDP_SLOT];+#[derive(Clone, Copy, webidl::WebIdlEnum)]+#[webidl(name = "RTCSdpType", rename_all = "kebab-case")]+enum SdpType {+ Offer,+ Pranswer,+ Answer,+ Rollback,+}++// The deprecated data-model constructor allows an omitted type. PeerConnection+// description algorithms retain their own required description constraints.+#[derive(webidl::WebIdlDictionary)]+#[webidl(prefix = "RTCSessionDescriptionInit")]+struct SessionDescriptionInit<'s> {+ #[webidl(converter = "raw", default = DictionaryDomString::default())]+ sdp: DictionaryDomString<'s>,+ #[webidl(converter = "enum")]+ r#type: Option<SdpType>,+}++#[derive(webidl::WebIdlArgs)]+#[webidl(prefix = "RTCSessionDescription")]+struct SessionDescriptionArgs<'s> {+ #[webidl(dictionary)]+ init: SessionDescriptionInit<'s>,+}+#[derive(WebApiObject)]#[webapi(interface = web_api_interfaces::RTCSessionDescription)]struct SessionDescriptionObjectDeclaration<'scope> {#[webapi(slot = DESCRIPTION_TYPE_SLOT)]- r#type: v8::Local<'scope, v8::String>,+ r#type: v8::Local<'scope, v8::Value>,#[webapi(slot = DESCRIPTION_SDP_SLOT)]sdp: v8::Local<'scope, v8::String>,}@@ -52,59 +79,15 @@ pub(in crate::context_bootstrap) fn rtc_session_description_constructor_callbackthrow_type_error(scope, "RTCSessionDescription constructor requires 'new'.");return;}- let dictionary = match webidl::dictionary_value(- args.get(0),- webidl::Context::argument("RTCSessionDescription", 1),- ) {- Ok(Some(dictionary)) => dictionary,- Ok(None) => {- throw_type_error(scope, "RTCSessionDescriptionInit requires type.");- return;- }- Err(error) => {- webidl::throw_error(scope, &error);- return;- }- };- // WebIDL converts dictionary members in lexical order, including defaults.- // SDP is a DOMString: retain the V8 string, including lone UTF-16 surrogates.- // Its contents are not validated by this legacy data-model constructor.- let Some(raw_sdp) = dictionary.get(scope, v8str(scope, "sdp").into()) else {- return;- };- let sdp = if raw_sdp.is_undefined() {- v8str(scope, "")- } else {- if raw_sdp.is_symbol() {- throw_type_error(scope, "Cannot convert a Symbol to a DOMString.");- return;- }- let Some(sdp) = raw_sdp.to_string(scope) else {- return;- };- sdp- };- let Some(raw_type) = dictionary.get(scope, v8str(scope, "type").into()) else {+ let Some(args_init) = webidl::parse_args::<SessionDescriptionArgs>(scope, &args) else {return;};- if raw_type.is_undefined() {- throw_type_error(scope, "RTCSessionDescriptionInit requires type.");- return;- }- if raw_type.is_symbol() {- throw_type_error(scope, "Cannot convert a Symbol to an RTCSdpType.");- return;- }- let Some(kind) = raw_type.to_string(scope) else {- return;- };- if !matches!(- kind.to_rust_string_lossy(scope).as_str(),- "offer" | "pranswer" | "answer" | "rollback"- ) {- throw_type_error(scope, "Invalid RTCSdpType.");- return;- }+ let sdp = args_init.init.sdp.into_value(scope);+ let kind: v8::Local<'s, v8::Value> = args_init+ .init+ .r#type+ .map(|value| v8str(scope, webidl::WebIdlEnumSnapshot::snapshot_token(&value)).into())+ .unwrap_or_else(|| v8::null(scope).into());if SessionDescriptionObjectDeclaration::new(kind, sdp).initialize(scope, args.this()).is_err()@@ -145,9 +128,7 @@ fn description_to_json_callback<'s>(args: v8::FunctionCallbackArguments<'s>,mut rv: v8::ReturnValue<'s, v8::Value>,) {- let Some(kind) = get_private_value(scope, args.this(), DESCRIPTION_TYPE_SLOT)- .and_then(|value| v8::Local::<v8::String>::try_from(value).ok())- else {+ let Some(kind) = get_private_value(scope, args.this(), DESCRIPTION_TYPE_SLOT) else {throw_type_error(scope, "Illegal invocation");return;};diff --git a/moli-renderer-v8/src/script_vm/tests/browser_api/mod.rs b/moli-renderer-v8/src/script_vm/tests/browser_api/mod.rsindex 0963826bf..4327737dc 100644--- a/moli-renderer-v8/src/script_vm/tests/browser_api/mod.rs+++ b/moli-renderer-v8/src/script_vm/tests/browser_api/mod.rs@@ -57,6 +57,7 @@ mod pointing_event_init;mod popup_hyperlinks;mod promise_rejection;mod request_init;+mod rtc_dictionary_init;mod rtc_error;mod security_policy;mod security_policy_event_init;diff --git a/moli-renderer-v8/src/script_vm/tests/browser_api/rtc_dictionary_init.rs b/moli-renderer-v8/src/script_vm/tests/browser_api/rtc_dictionary_init.rsnew file mode 100644index 000000000..b09dc8bdc--- /dev/null+++ b/moli-renderer-v8/src/script_vm/tests/browser_api/rtc_dictionary_init.rs@@ -0,0 +1,13 @@+use super::*;++#[test]+fn rtc_constructor_dictionaries_convert_once_and_preserve_v8_strings() {+ let mut vm = new_storage_html_test_vm("https://rtc-constructor-dictionary.test/");+ assert_eq!(+ vm.eval(include_str!(+ "../../../../tests/fixtures/rtc-constructor-dictionaries.js"+ ))+ .unwrap(),+ "true"+ );+}diff --git a/moli-renderer-v8/src/script_vm/tests/browser_api/session_description.rs b/moli-renderer-v8/src/script_vm/tests/browser_api/session_description.rsindex faadaf52b..01cea38c2 100644--- a/moli-renderer-v8/src/script_vm/tests/browser_api/session_description.rs+++ b/moli-renderer-v8/src/script_vm/tests/browser_api/session_description.rs@@ -1,24 +1,28 @@use super::*;#[test]-fn rtc_session_description_requires_a_dictionary_with_a_valid_type() {+fn rtc_session_description_accepts_optional_dictionary_and_validates_supplied_type() {let mut vm = new_storage_test_vm("http://session-description.test/");let result = vm.eval(r#"- (() => {+(() => {const rejects = callback => {try { callback(); return false; } catch (error) { return error instanceof TypeError; }};const checks = [- RTCSessionDescription.length === 1,+ RTCSessionDescription.length === 0,RTCSessionDescription.name === 'RTCSessionDescription',rejects(() => RTCSessionDescription({type: 'offer'})),- rejects(() => new RTCSessionDescription())+ new RTCSessionDescription().type === null];- for (const value of [undefined, null, {}, true, 3, 'offer', Symbol(), 1n,- {type: undefined}, {type: null}, {type: ''}, {type: 'Offer'},+ for (const value of [true, 3, 'offer', Symbol(), 1n,+ {type: null}, {type: ''}, {type: 'Offer'},{type: ' offer'}, {type: 'answer\0'}, {type: Symbol()}, {type: 1}]) {checks.push(rejects(() => new RTCSessionDescription(value)));}+ for (const value of [undefined, null, {}, {type: undefined}]) {+ const description = new RTCSessionDescription(value);+ checks.push(description.type === null, description.sdp === '', description.toJSON().type === null);+ }for (const type of ['offer', 'pranswer', 'answer', 'rollback']) {const description = new RTCSessionDescription({type});checks.push(description.type === type, description.sdp === '');@@ -34,7 +38,7 @@ fn rtc_session_description_requires_a_dictionary_with_a_valid_type() {checks.push(rejects(() => new RTCSessionDescription({type: 'offer', sdp: Symbol()})));return checks.every(Boolean);})()- "#).expect("RTCSessionDescription should require an RTCSdpType and retain DOMString SDP without validation");+"#).expect("RTCSessionDescription should accept legacy defaults and validate a supplied RTCSdpType and retain DOMString SDP without validation");assert_eq!(result, "true");}@@ -42,7 +46,7 @@ fn rtc_session_description_requires_a_dictionary_with_a_valid_type() {fn rtc_session_description_converts_members_in_order_and_preserves_exceptions() {let mut vm = new_storage_test_vm("https://session-description-conversion.test/");let result = vm.eval(r#"- (() => {+(() => {const reads = [];const dictionary = Object.create({sdp: {toString() { reads.push('convert sdp'); return 'sdp'; }},@@ -70,22 +74,24 @@ fn rtc_session_description_converts_members_in_order_and_preserves_exceptions()checks.push(false);} catch (caught) { checks.push(caught instanceof TypeError, !typeRead); }let sdpRead = false;- try { new RTCSessionDescription({get sdp() { sdpRead = true; return ''; }}); checks.push(false); }- catch (caught) { checks.push(caught instanceof TypeError, sdpRead); }+ const emptyType = new RTCSessionDescription({get sdp() { sdpRead = true; return ''; }});+ checks.push(emptyType.type === null, sdpRead);Object.defineProperty(Object.prototype, 'type', {configurable: true, get() { throw error; }});try {for (const value of [undefined, null]) {- try { new RTCSessionDescription(value); checks.push(false); }- catch (caught) { checks.push(caught instanceof TypeError); }+ const empty = new RTCSessionDescription(value);+ checks.push(empty.type === null, empty.sdp === '');}+ try { new RTCSessionDescription({}); checks.push(false); }+ catch (caught) { checks.push(caught === error); }} finally { delete Object.prototype.type; }const clone = new RTCSessionDescription(description);checks.push(clone !== description, clone.type === 'answer', clone.sdp === 'sdp');return checks.every(Boolean);})()- "#).expect("RTCSessionDescription dictionary conversion should observe WebIDL order and original exceptions");+"#).expect("RTCSessionDescription dictionary conversion should observe WebIDL order and original exceptions");assert_eq!(result, "true");}diff --git a/moli-renderer-v8/tests/fixtures/rtc-constructor-dictionaries.js b/moli-renderer-v8/tests/fixtures/rtc-constructor-dictionaries.jsnew file mode 100644index 000000000..e8fd571d4--- /dev/null+++ b/moli-renderer-v8/tests/fixtures/rtc-constructor-dictionaries.js@@ -0,0 +1,52 @@+(() => {+ const assert = (value, label) => { if (!value) throw Error(label); };+ const cases = [[RTCSessionDescription, ['sdp', 'type'], {type:'offer'}],+ [RTCIceCandidate, ['candidate', 'sdpMLineIndex', 'sdpMid', 'usernameFragment'], {sdpMid:'0'}]];+ for (const [C,members,values] of cases) {+ for (const value of [1, true, 'init', 1n, Symbol()]) {+ let caught; try {new C(value);} catch(e) {caught=e;}+ assert(caught instanceof TypeError, C.name + ' primitive dictionary');+ }+ const reads = [];+ new C(new Proxy({}, {get(_,key) {+ if(members.includes(key)) reads.push(key); return key in values ? values[key] : undefined;+ }, has() {throw Error('Get required');}}));+ assert(reads.join() === members.join(), C.name + ' lexical order: ' + reads);+ for (const member of members) for (const sentinel of [{}, null, undefined, 7]) {+ reads.length=0;let caught=Symbol();+ try {new C(new Proxy({}, {get(_,key) {+ if(members.includes(key)) reads.push(key);+ if(key === member) throw sentinel;return key in values ? values[key] : undefined;+ }}));} catch(e) {caught=e;}+ assert(caught === sentinel, C.name + '/' + member + ' original exception');+ assert(reads.join() === members.slice(0,members.indexOf(member)+1).join(), C.name + '/' + member + ' stop');+ }+ }+ for (const input of [undefined,null,{}, {type:undefined}]) {+ const value = new RTCSessionDescription(input);+ assert(value.type === null && value.sdp === '' && value.toJSON().type === null, 'legacy optional description type');+ }+ for (const type of [null,'bad',Symbol()]) {+ let caught;try {new RTCSessionDescription({type});} catch(e) {caught=e;}+ assert(caught instanceof TypeError, 'SDP enum validation');+ }+ const raw = '\ud800\0\udc00';+ const description = new RTCSessionDescription({type:'offer',sdp:raw});+ assert(description.sdp === raw && description.toJSON().sdp === raw, 'SDP lossless UTF16');+ const candidate = new RTCIceCandidate({candidate:raw,sdpMid:raw,sdpMLineIndex:1,usernameFragment:raw});+ assert(candidate.candidate === raw && candidate.sdpMid === raw && candidate.usernameFragment === raw, 'ICE lossless UTF16');+ assert(candidate.toJSON().candidate === raw && candidate.toJSON().usernameFragment === raw, 'ICE JSON lossless UTF16');+ for (const [value,expected] of [[-1,65535],[65536,0],[1.9,1],[NaN,0],[Infinity,0]])+ assert(new RTCIceCandidate({sdpMid:'0',sdpMLineIndex:value}).sdpMLineIndex === expected, 'ICE unsigned short conversion');+ for (const value of [undefined,null,{}]) {+ let caught;try {new RTCIceCandidate(value);} catch(e) {caught=e;}+ assert(caught instanceof TypeError, 'ICE needs mid or line after conversion');+ }+ const sentinel={};let later=0,caught;+ try {new RTCSessionDescription({sdp:{toString(){throw sentinel;}},get type(){later++;return 'offer';}});} catch(e){caught=e;}+ assert(caught===sentinel && later===0, 'SDP ToString abrupt completion');+ let stringCalls=0;+ const wrapped={toString(){stringCalls++;return raw;}};+ assert(new RTCSessionDescription({type:'offer',sdp:wrapped}).sdp===raw && stringCalls===1,'SDP coerces once');+ return true;+})()