From e0ec25487226fc699104a25c1084e6155f22f5e2 Mon Sep 17 00:00:00 2001 From: Omar Rizwan Date: Wed, 15 Sep 2021 23:36:45 -0700 Subject: [PATCH] extension: support allFrames in evals/ tweak routes.html language slightly --- extension/background.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/extension/background.js b/extension/background.js index 5d34874..4bd9bec 100644 --- a/extension/background.js +++ b/extension/background.js @@ -362,12 +362,16 @@ function createWritableDirectory() { Routes["/tabs/by-id/#TAB_ID/evals/:FILENAME"] = { ...evals.routeForFilename, // FIXME: use $0 here + // FIXME: document allFrames option usage: ['echo "2 + 2" > tabs/by-id/#TAB_ID/evals/twoplustwo.js', 'cat tabs/by-id/#TAB_ID/evals/twoplustwo.js.result'], async write(req) { const ret = await evals.routeForFilename.write(req); const code = evals.directory[req.path]; - evals.directory[req.path + '.result'] = JSON.stringify((await browser.tabs.executeScript(req.tabId, {code}))[0]) + '\n'; + const allFrames = req.path.endsWith('.all-frames.js'); + // TODO: return other results beyond [0] (when all-frames is on) + const result = (await browser.tabs.executeScript(req.tabId, {code, allFrames}))[0]; + evals.directory[req.path + '.result'] = JSON.stringify(result) + '\n'; return ret; } }; @@ -699,7 +703,7 @@ Routes["/runtime/routes.html"] = makeRouteWithContents(async () => {

This page is automatically generated from extension/background.js in the TabFS source code.

It documents each of the folders and files that TabFS serves up from your browser.

-

Variables here, like :TAB_TITLE and #TAB_ID, are stand-ins for concrete values of what you actually have open in your browser.

+

Variables in this document, like :TAB_TITLE and #TAB_ID, are stand-ins for concrete values of what you actually have open in your browser in a running TabFS.

(work in progress)

` + Object.entries(Routes).map(([path, {usage, description, __isInfill, readdir}]) => {