Compare commits

..

No commits in common. "82a1d6722def33450733efdffbf94f766ba1fbf5" and "0a6c542c767f7cb13b577e4fb65af681a55c0aa8" have entirely different histories.

3 changed files with 2 additions and 48 deletions

View file

@ -449,26 +449,6 @@ router["/tabs/by-id/*/active"] = {
});
})();
router["/tabs/by-id/*/textareas"] = {
async readdir({path}) {
const tabId = parseInt(pathComponent(path, -2));
// TODO: assign new IDs to textareas without them?
const code = `Array.from(document.querySelectorAll('textarea')).map(e => e.id).filter(id => id)`
const ids = (await browser.tabs.executeScript(tabId, {code}))[0];
return { entries: [".", "..", ...ids.map(id => `${id}.txt`)] };
}
};
router["/tabs/by-id/*/textareas/*"] = defineFile(async path => {
const [tabId, textareaId] = [parseInt(pathComponent(path, -3)), pathComponent(path, -1).slice(0, -4)];
const code = `document.getElementById('${textareaId}').value`;
const textareaValue = (await browser.tabs.executeScript(tabId, {code}))[0];
return textareaValue;
}, async (path, buf) => {
const [tabId, textareaId] = [parseInt(pathComponent(path, -3)), pathComponent(path, -1).slice(0, -4)];
const code = `document.getElementById('${textareaId}').value = unescape('${escape(buf)}')`;
await browser.tabs.executeScript(tabId, {code});
});
router["/tabs/by-title"] = {
getattr() {
return {

View file

@ -1,10 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Textarea Test Page</title>
</head>
<body>
<textarea id="ta">initial text</textarea>
</body>
</html>

View file

@ -79,27 +79,11 @@ int main() {
}
// try to shorten the URL (#40)
/* assert(system("echo about:blank > ../fs/mnt/tabs/last-focused/url.txt") == 0); */
/* assert(file_contents_equal("../fs/mnt/tabs/last-focused/url.txt", "about:blank")); */
assert(system("echo about:blank > ../fs/mnt/tabs/last-focused/url.txt") == 0);
assert(file_contents_equal("../fs/mnt/tabs/last-focused/url.txt", "about:blank"));
assert(system("echo remove > ../fs/mnt/tabs/last-focused/control") == 0);
}
{
assert(system("echo file://$(pwd)/test-textarea.html > ../fs/mnt/tabs/create") == 0);
{
FILE* console = fopen("../fs/mnt/tabs/last-focused/console", "r");
assert(system("echo \"console.log(document.getElementById('ta').value)\" > ../fs/mnt/tabs/last-focused/execute-script") == 0);
char ta[100] = {0}; fread(ta, 1, sizeof(ta), console);
assert(strcmp(ta, "initial text") == 0);
assert(file_contents_equal("../fs/mnt/tabs/last-focused/textareas/ta.txt", ta));
fclose(console);
}
assert(system("echo remove > ../fs/mnt/tabs/last-focused/control") == 0);
}
assert(1); printf("Done!\n");
}