OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 // Flags: --allow-natives-syntax --harmony-dynamic-import |
| 6 |
| 7 var ran = false; |
| 8 |
| 9 var x = { |
| 10 get toString() { return undefined; } |
| 11 }; |
| 12 import(x); |
| 13 |
| 14 var x = { |
| 15 toString() { |
| 16 throw new Error('42 is the answer'); |
| 17 } |
| 18 }; |
| 19 import(x); |
| 20 |
| 21 var x = { |
| 22 get toString() { |
| 23 throw new Error('42 is the answer'); |
| 24 } |
| 25 }; |
| 26 import(x); |
| 27 |
| 28 async function test() { |
| 29 try { |
| 30 let x = { |
| 31 toString() { |
| 32 throw new Error('42 is the answer'); |
| 33 } |
| 34 }; |
| 35 |
| 36 let namespace = await import(x); |
| 37 %AbortJS('failure: this should throw'); |
| 38 } catch(e) { |
| 39 assertEquals(e.message, '42 is the answer'); |
| 40 ran = true; |
| 41 } |
| 42 } |
| 43 |
| 44 test(); |
| 45 |
| 46 %RunMicrotasks(); |
| 47 |
| 48 assertTrue(ran); |
| 49 |
| 50 ran = false; |
| 51 async function test() { |
| 52 try { |
| 53 let x = { |
| 54 get toString() { |
| 55 throw new Error('42 is the answer'); |
| 56 } |
| 57 }; |
| 58 |
| 59 let namespace = await import(x); |
| 60 %AbortJS('failure: this should throw'); |
| 61 } catch(e) { |
| 62 assertEquals(e.message, '42 is the answer'); |
| 63 ran = true; |
| 64 } |
| 65 } |
| 66 |
| 67 test(); |
| 68 |
| 69 %RunMicrotasks(); |
| 70 |
| 71 assertTrue(ran); |
| 72 |
| 73 ran = false; |
| 74 async function test() { |
| 75 try { |
| 76 let x = { |
| 77 get toString() { return undefined; } |
| 78 }; |
| 79 let namespace = await import(x); |
| 80 %AbortJS('failure: this should throw'); |
| 81 } catch(e) { |
| 82 assertEquals(e.message, 'Cannot convert object to primitive value'); |
| 83 ran = true; |
| 84 } |
| 85 } |
| 86 |
| 87 test(); |
| 88 |
| 89 %RunMicrotasks(); |
| 90 |
| 91 assertTrue(ran); |
OLD | NEW |