-
Notifications
You must be signed in to change notification settings - Fork 79
Description
Intro
Now documentIds are getting common in browsers and APIs like tabGroups are getting their own namespace, it seems odd for documents not to have the same. Turns out by moving many APIs to browser.documents you end up with much more semantic and elegant APIs. This issue explores how such namespace could look like.
Design
namespace documents {
// replacing `browser.webNavigation.getFrame`
function get(documentId: string): Promise<Document>;
// see https://github.com/w3c/webextensions/issues/77
function sendMessage(
documentId: string,
message: any,
): Promise<any>;
};
// replacing https://github.com/w3c/webextensions/pull/586
// replacing webNavigation.getAllFrames()
function query(queryInfo: {
documentIds?: string[];
tabIds?: number[];
frameIds?: number[];
windowIds?: number[];
url?: string;
documentLifecycle?: DocumentLifecycle;
status?: DocumentStatus;
frameType?: FrameType;
}): Promise<Document[]>;
// replacing runtime.getDocumentId()
// see https://github.com/w3c/webextensions/issues/800
function getId(context: Window | HTMLIFrameElement): Promise<string>;
// focus management see https://github.com/w3c/webextensions/pull/817
function focus(documentId: string): Promise<string>;
}In addition, lifecycle events from webNavigation can be moved to browser.documents. With the exception of onTabReplaced, which seems to sit best under browser.tabs. These events would only be available with the webNavigation API. Effectively deprecating the webNavigation namespace (but not the webNavigation permission).
As for permissions, it seems for many of these APIs, the webNavigation permission is too dramatic, with the exception of the lifecycle events and potentially parts of the browser.documents.query method.