aboutsummaryrefslogtreecommitdiffstats
path: root/extension
diff options
context:
space:
mode:
authorOmar Rizwan <omar.rizwan@gmail.com>2019-02-27 22:06:37 -0800
committerOmar Rizwan <omar.rizwan@gmail.com>2019-02-27 22:06:37 -0800
commit73f8bc754e200c041e17e613a61dfc35db414b66 (patch)
tree0b2aadcc2fc1edf75e35c5af12dacb921036d94f /extension
parent74c794d75c7205123c4dc37e7a997507b61be98b (diff)
base64 hack to handle binary files.
add memory fences because why not.
Diffstat (limited to 'extension')
-rw-r--r--extension/background.js12
1 files changed, 9 insertions, 3 deletions
diff --git a/extension/background.js b/extension/background.js
index e75618d..6653edd 100644
--- a/extension/background.js
+++ b/extension/background.js
@@ -126,13 +126,18 @@ const router = {
for (let resource of frameTree.resources) {
const resourceSuffix = sanitize(String(resource.url).slice(0, 200));
if (resourceSuffix === suffix) {
- const {content} = await sendDebuggerCommand(tabId, "Page.getResourceContent", {
+ let {base64Encoded, content} = await sendDebuggerCommand(tabId, "Page.getResourceContent", {
frameId: frameTree.frame.id,
url: resource.url
});
+ if (base64Encoded) {
+ const buf = btoa(atob(content).substr(offset, size));
+ return { buf, base64Encoded: true };
+ }
return content.substr(offset, size);
}
}
+ throw new UnixError(unix.ENOENT);
}
}
}
@@ -226,11 +231,13 @@ async function onmessage(event) {
};
} else if (req.op === 'read') {
- const buf = await read(req.path, req.fh, req.size, req.offset)
+ const ret = await read(req.path, req.fh, req.size, req.offset)
+ const buf = typeof ret === 'string' ? ret : ret.buf;
response = {
op: 'read',
buf
};
+ if (ret.base64Encoded) response.base64Encoded = ret.base64Encoded;
} else if (req.op === 'release') {
await release(req.path, req.fh);
@@ -263,7 +270,6 @@ async function onmessage(event) {
}
/* console.timeEnd(req.op + ':' + req.path);*/
- response.id = req.id;
console.log('resp', response);
ws.send(JSON.stringify(response));
};