@@ -41,11 +41,11 @@ d8.file.execute("test/mjsunit/wasm/exceptions-utils.js");
4141 } } ) ;
4242
4343 let obj = { } ;
44+ // Creating a WA.Exception with the JSTag explicitly is not allowed.
45+ assertThrows ( ( ) => new WebAssembly . Exception ( WebAssembly . JSTag , [ obj ] ) , TypeError ) ;
4446
4547 // Catch with implicit wrapping.
4648 assertSame ( obj , instance . exports . test ( obj ) ) ;
47- // Catch with explicit wrapping.
48- assertSame ( obj , instance . exports . test ( new WebAssembly . Exception ( WebAssembly . JSTag , [ obj ] ) ) ) ;
4949 // Don't catch with explicit wrapping.
5050 let not_js_tag = new WebAssembly . Tag ( { parameters :[ 'externref' ] } ) ;
5151 let exn = new WebAssembly . Exception ( not_js_tag , [ obj ] ) ;
@@ -63,10 +63,6 @@ d8.file.execute("test/mjsunit/wasm/exceptions-utils.js");
6363 // Catch with explicit wrapping.
6464 assertSame ( obj , instance . exports . test ( new WebAssembly . Exception ( not_js_tag , [ obj ] ) ) ) ;
6565 // Don't catch with explicit wrapping.
66- exn = new WebAssembly . Exception ( WebAssembly . JSTag , [ obj ] ) ;
67- // TODO(thibaudm): Should the exception get implicitly unwrapped when it
68- // bubbles up from wasm to JS, even though it was wrapped explicitly?
69- assertThrowsEquals ( ( ) => instance . exports . test ( exn ) , exn ) ;
7066 // Don't catch with implicit wrapping.
7167 assertThrowsEquals ( ( ) => instance . exports . test ( obj ) , obj ) ;
7268} ) ( ) ;
@@ -107,8 +103,6 @@ d8.file.execute("test/mjsunit/wasm/exceptions-utils.js");
107103
108104 // Catch with implicit wrapping.
109105 assertSame ( obj , instance . exports . test ( obj ) ) ;
110- // Catch with explicit wrapping.
111- assertSame ( obj , instance . exports . test ( new WebAssembly . Exception ( WebAssembly . JSTag , [ obj ] ) ) ) ;
112106 // Don't catch with explicit wrapping.
113107 let not_js_tag = new WebAssembly . Tag ( { parameters :[ 'externref' ] } ) ;
114108 let exn = new WebAssembly . Exception ( not_js_tag , [ obj ] ) ;
@@ -125,11 +119,6 @@ d8.file.execute("test/mjsunit/wasm/exceptions-utils.js");
125119
126120 // Catch with explicit wrapping.
127121 assertSame ( obj , instance . exports . test ( new WebAssembly . Exception ( not_js_tag , [ obj ] ) ) ) ;
128- // Don't catch with explicit wrapping.
129- exn = new WebAssembly . Exception ( WebAssembly . JSTag , [ obj ] ) ;
130- // TODO(thibaudm): Should the exception get implicitly unwrapped when it
131- // bubbles up from wasm to JS, even though it was wrapped explicitly?
132- assertThrowsEquals ( ( ) => instance . exports . test ( exn ) , exn ) ;
133122 // Don't catch with implicit wrapping.
134123 assertThrowsEquals ( ( ) => instance . exports . test ( obj ) , obj ) ;
135124} ) ( ) ;
@@ -171,11 +160,6 @@ d8.file.execute("test/mjsunit/wasm/exceptions-utils.js");
171160
172161 // Catch and rethrown with implicit wrapping.
173162 assertThrowsEquals ( ( ) => instance . exports . test ( obj ) , obj ) ;
174- // Catch and rethrown with explicit wrapping.
175- // TODO: Should the exception get implicitly unwrapped when it
176- // is rethrown from wasm to JS, even though it was wrapped explicitly?
177- let exn = new WebAssembly . Exception ( WebAssembly . JSTag , [ obj ] ) ;
178- assertThrowsEquals ( ( ) => instance . exports . test ( exn ) , exn ) ;
179163 // Don't catch with explicit wrapping.
180164 let not_js_tag = new WebAssembly . Tag ( { parameters :[ 'externref' ] } ) ;
181165 exn = new WebAssembly . Exception ( not_js_tag , [ obj ] ) ;
@@ -193,11 +177,29 @@ d8.file.execute("test/mjsunit/wasm/exceptions-utils.js");
193177 // Catch and rethrow with explicit wrapping -> not unwrapped in this case.
194178 exn = new WebAssembly . Exception ( not_js_tag , [ obj ] ) ;
195179 assertThrowsEquals ( ( ) => instance . exports . test ( exn ) , exn ) ;
196- // Don't catch with explicit wrapping.
197- exn = new WebAssembly . Exception ( WebAssembly . JSTag , [ obj ] ) ;
198- // TODO(thibaudm): Should the exception get implicitly unwrapped when it
199- // bubbles up from wasm to JS, even though it was wrapped explicitly?
200- assertThrowsEquals ( ( ) => instance . exports . test ( exn ) , exn ) ;
201180 // Don't catch with implicit wrapping.
202181 assertThrowsEquals ( ( ) => instance . exports . test ( obj ) , obj ) ;
203182} ) ( ) ;
183+
184+ ( function TestThrowJSTag ( ) {
185+ print ( arguments . callee . name ) ;
186+ let builder = new WasmModuleBuilder ( ) ;
187+ let js_tag = builder . addImportedTag ( "" , "tag" , kSig_v_r ) ;
188+
189+ // Throw a JS object with WebAssembly.JSTag and check that we can catch
190+ // it as-is from JavaScript.
191+ builder . addFunction ( "test" , kSig_v_r )
192+ . addBody ( [
193+ kExprLocalGet , 0 ,
194+ kExprThrow , js_tag ,
195+ ] )
196+ . exportFunc ( ) ;
197+
198+ let instance = builder . instantiate ( { "" : {
199+ tag : WebAssembly . JSTag ,
200+ } } ) ;
201+
202+ let obj = { } ;
203+ assertThrowsEquals ( ( ) => instance . exports . test ( obj ) , obj ) ;
204+ assertThrowsEquals ( ( ) => instance . exports . test ( 5 ) , 5 ) ;
205+ } ) ( ) ;
0 commit comments