Commit e285b712 authored by sander's avatar sander Committed by Commit Bot

Support reading a binary file as ArrayBuffer

Calling `read(filename, 'binary')` should return an ArrayBuffer like
SpiderMonkey does. It is possible to call `readbuffer` instead, but that
function is not available in the SpiderMonkey JS shell.

BUG=v8:6464
R=bradnelson@chromium.org

Review-Url: https://codereview.chromium.org/2922353002
Cr-Commit-Position: refs/heads/master@{#45776}
parent 92c4588d
......@@ -1196,6 +1196,13 @@ void Shell::Read(const v8::FunctionCallbackInfo<v8::Value>& args) {
Throw(args.GetIsolate(), "Error loading file");
return;
}
if (args.Length() == 2) {
String::Utf8Value format(args[1]);
if (*format && std::strcmp(*format, "binary") == 0) {
ReadBuffer(args);
return;
}
}
Local<String> source = ReadFile(args.GetIsolate(), *file);
if (source.IsEmpty()) {
Throw(args.GetIsolate(), "Error loading file");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment