@@ -47,7 +47,10 @@ const bufferSource = fixtures.readSync('simple.wasm');
47
47
48
48
Object . defineProperty ( instance , 'exports' , {
49
49
get ( ) {
50
- return { _initialize : 5 , memory : new Uint8Array ( ) } ;
50
+ return {
51
+ _initialize : 5 ,
52
+ memory : new WebAssembly . Memory ( { initial : 1 } ) ,
53
+ } ;
51
54
} ,
52
55
} ) ;
53
56
assert . throws (
@@ -70,7 +73,7 @@ const bufferSource = fixtures.readSync('simple.wasm');
70
73
return {
71
74
_start ( ) { } ,
72
75
_initialize ( ) { } ,
73
- memory : new Uint8Array ( ) ,
76
+ memory : new WebAssembly . Memory ( { initial : 1 } ) ,
74
77
} ;
75
78
}
76
79
} ) ;
@@ -97,55 +100,11 @@ const bufferSource = fixtures.readSync('simple.wasm');
97
100
( ) => { wasi . initialize ( instance ) ; } ,
98
101
{
99
102
code : 'ERR_INVALID_ARG_TYPE' ,
100
- message : / " i n s t a n c e \. e x p o r t s \. m e m o r y " p r o p e r t y m u s t b e o f t y p e o b j e c t /
103
+ message : / " i n s t a n c e \. e x p o r t s \. m e m o r y " p r o p e r t y m u s t b e a W e b A s s e m b l y \. M e m o r y o b j e c t /
101
104
}
102
105
) ;
103
106
}
104
107
105
- {
106
- // Verify that a non-ArrayBuffer memory.buffer is rejected.
107
- const wasi = new WASI ( { } ) ;
108
- const wasm = await WebAssembly . compile ( bufferSource ) ;
109
- const instance = await WebAssembly . instantiate ( wasm ) ;
110
-
111
- Object . defineProperty ( instance , 'exports' , {
112
- get ( ) {
113
- return {
114
- _initialize ( ) { } ,
115
- memory : { } ,
116
- } ;
117
- }
118
- } ) ;
119
- // The error message is a little white lie because any object
120
- // with a .buffer property of type ArrayBuffer is accepted,
121
- // but 99% of the time a WebAssembly.Memory object is used.
122
- assert . throws (
123
- ( ) => { wasi . initialize ( instance ) ; } ,
124
- {
125
- code : 'ERR_INVALID_ARG_TYPE' ,
126
- message : / " i n s t a n c e \. e x p o r t s \. m e m o r y \. b u f f e r " p r o p e r t y m u s t b e a n W e b A s s e m b l y \. M e m o r y /
127
- }
128
- ) ;
129
- }
130
-
131
- {
132
- // Verify that an argument that duck-types as a WebAssembly.Instance
133
- // is accepted.
134
- const wasi = new WASI ( { } ) ;
135
- const wasm = await WebAssembly . compile ( bufferSource ) ;
136
- const instance = await WebAssembly . instantiate ( wasm ) ;
137
-
138
- Object . defineProperty ( instance , 'exports' , {
139
- get ( ) {
140
- return {
141
- _initialize ( ) { } ,
142
- memory : { buffer : new ArrayBuffer ( 0 ) } ,
143
- } ;
144
- }
145
- } ) ;
146
- wasi . initialize ( instance ) ;
147
- }
148
-
149
108
{
150
109
// Verify that a WebAssembly.Instance from another VM context is accepted.
151
110
const wasi = new WASI ( { } ) ;
0 commit comments