Skip to content

Commit acbc19b

Browse files
basicercopy
authored andcommitted
Some small fixes:
- Use the response contructor in the fetch unit tests instead of faking it - Allow setting size of multiple virtio-consoles independently
1 parent 4e15e2e commit acbc19b

File tree

2 files changed

+13
-25
lines changed

2 files changed

+13
-25
lines changed

src/virtio_console.js

+9-5
Original file line numberDiff line numberDiff line change
@@ -215,21 +215,25 @@ function VirtioConsole(cpu, bus)
215215
}, this);
216216

217217
this.bus.register("virtio-console" + port + "-resize", function(size) {
218-
this.cols = size[0];
219-
this.rows = size[1];
218+
if(port === 0) {
219+
this.cols = size[0];
220+
this.rows = size[1];
221+
}
220222

221223
if(this.virtio.queues[2].is_configured() && this.virtio.queues[2].has_request()) {
222-
this.SendWindowSize(port);
224+
this.SendWindowSize(port, size[0], size[1]);
223225
}
224226
}, this);
225227
}
226228
}
227229

228-
VirtioConsole.prototype.SendWindowSize = function(port)
230+
VirtioConsole.prototype.SendWindowSize = function(port, cols = undefined, rows = undefined)
229231
{
232+
rows = rows || this.rows;
233+
cols = cols || this.cols;
230234
const bufchain = this.virtio.queues[2].pop_request();
231235
const buf = new Uint8Array(12);
232-
marshall.Marshall(["w", "h", "h", "h", "h"], [port, VIRTIO_CONSOLE_RESIZE, 0, this.rows, this.cols], buf, 0);
236+
marshall.Marshall(["w", "h", "h", "h", "h"], [port, VIRTIO_CONSOLE_RESIZE, 0, rows, cols], buf, 0);
233237
this.Send(2, bufchain, buf);
234238
};
235239

tests/devices/fetch_network.js

+4-20
Original file line numberDiff line numberDiff line change
@@ -223,27 +223,11 @@ emulator.add_listener("emulator-ready", function () {
223223
let headers = new Headers();
224224
headers.append("Content-Type", "text/plain");
225225
headers.append("Content-Length", contents.length);
226-
return new Promise(res => setTimeout(() => res((
227-
{
228-
status: 200,
229-
statusText: "OK",
230-
headers: headers,
231-
body: {
232-
getReader() {
233-
return {
234-
async read() {
235-
return {
236-
value: contents,
237-
done: true
238-
};
239-
}
240-
};
241-
}
242-
}
243-
}
244-
)), 50));
226+
return new Promise(res => setTimeout(() => res(new Response(contents, {
227+
headers
228+
})), 50));
245229
}
246-
return original_fetch.call(network_adapter, url, opts);
230+
return original_fetch(url, opts);
247231
};
248232
});
249233

0 commit comments

Comments
 (0)