mirror of
https://github.com/osnr/TabFS.git
synced 2024-06-10 09:52:21 +02:00
make windows/*/visible-tab.png. seems to work?
This commit is contained in:
parent
2d8bedcc4b
commit
c4d9cb7b54
|
@ -215,22 +215,6 @@ router["/tabs/by-id"] = {
|
||||||
router["/tabs/by-id/*/title.txt"] = withTab(tab => tab.title + "\n");
|
router["/tabs/by-id/*/title.txt"] = withTab(tab => tab.title + "\n");
|
||||||
router["/tabs/by-id/*/text.txt"] = fromScript(`document.body.innerText`);
|
router["/tabs/by-id/*/text.txt"] = fromScript(`document.body.innerText`);
|
||||||
})();
|
})();
|
||||||
router["/tabs/by-id/*/screenshot.png"] = { ...defineFile(async path => {
|
|
||||||
// FIXME: replace with captureTab
|
|
||||||
// FIXME: hide if tab is not focused
|
|
||||||
const tabId = parseInt(pathComponent(path, -2));
|
|
||||||
await TabManager.debugTab(tabId); await TabManager.enableDomainForTab(tabId, "Page");
|
|
||||||
|
|
||||||
const {data} = await sendDebuggerCommand(tabId, "Page.captureScreenshot");
|
|
||||||
return Uint8Array.from(atob(data), c => c.charCodeAt(0));
|
|
||||||
|
|
||||||
}), async getattr({path}) {
|
|
||||||
return {
|
|
||||||
st_mode: unix.S_IFREG | 0444,
|
|
||||||
st_nlink: 1,
|
|
||||||
st_size: 10000000 // hard-code to 10MB for now
|
|
||||||
};
|
|
||||||
} }
|
|
||||||
router["/tabs/by-id/*/control"] = {
|
router["/tabs/by-id/*/control"] = {
|
||||||
// echo remove > mnt/tabs/by-id/1644/control
|
// echo remove > mnt/tabs/by-id/1644/control
|
||||||
async write({path, buf}) {
|
async write({path, buf}) {
|
||||||
|
@ -356,8 +340,8 @@ router["/windows/last-focused"] = {
|
||||||
router["/windows/*/visible-tab.png"] = { ...defineFile(async path => {
|
router["/windows/*/visible-tab.png"] = { ...defineFile(async path => {
|
||||||
const windowId = parseInt(pathComponent(path, -2));
|
const windowId = parseInt(pathComponent(path, -2));
|
||||||
const dataUrl = await browser.tabs.captureVisibleTab(windowId, {format: 'png'});
|
const dataUrl = await browser.tabs.captureVisibleTab(windowId, {format: 'png'});
|
||||||
console.log(dataUrl);
|
return Uint8Array.from(atob(dataUrl.substr(("data:image/png;base64,").length)),
|
||||||
return dataUrl;
|
c => c.charCodeAt(0));
|
||||||
|
|
||||||
}), async getattr({path}) {
|
}), async getattr({path}) {
|
||||||
return {
|
return {
|
||||||
|
@ -424,7 +408,7 @@ for (let i = 10; i >= 0; i--) {
|
||||||
if (TESTING) { // I wish I could color this section with... a pink background, or something.
|
if (TESTING) { // I wish I could color this section with... a pink background, or something.
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
(async () => {
|
(async () => {
|
||||||
assert.deepEqual(await router['/tabs/by-id/*'].readdir(), { entries: ['.', '..', 'url.txt', 'title.txt', 'text.txt', 'screenshot.png', 'control', 'debugger'] });
|
assert.deepEqual(await router['/tabs/by-id/*'].readdir(), { entries: ['.', '..', 'url.txt', 'title.txt', 'text.txt', 'control', 'debugger'] });
|
||||||
assert.deepEqual(await router['/'].readdir(), { entries: ['.', '..', 'windows', 'extensions', 'tabs', 'runtime'] });
|
assert.deepEqual(await router['/'].readdir(), { entries: ['.', '..', 'windows', 'extensions', 'tabs', 'runtime'] });
|
||||||
assert.deepEqual(await router['/tabs'].readdir(), { entries: ['.', '..', 'create', 'by-id', 'by-title', 'last-focused'] });
|
assert.deepEqual(await router['/tabs'].readdir(), { entries: ['.', '..', 'create', 'by-id', 'by-title', 'last-focused'] });
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
"permissions": [
|
"permissions": [
|
||||||
"tabs", "tabCapture", "debugger", "nativeMessaging", "management",
|
"tabs", "tabCapture", "debugger", "nativeMessaging", "management",
|
||||||
"unlimitedStorage",
|
"unlimitedStorage",
|
||||||
"*://*/*"
|
"<all_urls>"
|
||||||
],
|
],
|
||||||
|
|
||||||
"background": {
|
"background": {
|
||||||
|
|
4
test.c
4
test.c
|
@ -24,11 +24,11 @@ char* expand(char* phrase) { // expand path with wildcard
|
||||||
|
|
||||||
// integration tests
|
// integration tests
|
||||||
int main() {
|
int main() {
|
||||||
system("node extension/background.js"); // run quick local JS tests
|
assert(system("node extension/background.js") == 0); // run quick local JS tests
|
||||||
|
|
||||||
// reload the extension so we know it's the latest code.
|
// reload the extension so we know it's the latest code.
|
||||||
system("echo reload > fs/mnt/runtime/reload"); // this may error, but it should still have effect
|
system("echo reload > fs/mnt/runtime/reload"); // this may error, but it should still have effect
|
||||||
sleep(3);
|
sleep(4);
|
||||||
|
|
||||||
assert(system("echo about:blank > fs/mnt/tabs/create") == 0);
|
assert(system("echo about:blank > fs/mnt/tabs/create") == 0);
|
||||||
assert(file_contents_equal("fs/mnt/tabs/last-focused/url.txt", "about:blank"));
|
assert(file_contents_equal("fs/mnt/tabs/last-focused/url.txt", "about:blank"));
|
||||||
|
|
Loading…
Reference in a new issue