skeleton for AppleScript-JavaScript interface (#549)

This commit is contained in:
Cameron Kaiser 2019-03-15 22:59:27 -07:00
parent b360417953
commit 8868813757
3 changed files with 49 additions and 0 deletions

View File

@ -978,6 +978,11 @@ BrowserGlue.prototype = {
win.skipNextCanClose = true;
win.close();
}
},
runScriptInTabAtIndexInWindow : function(index, window_index,
script) {
throw Components.Exception("NYI", Cr.NS_ERROR_FAILURE);
return null;
}
}

View File

@ -142,6 +142,20 @@ interface nsIApplescriptService : nsISupports
* @param index The window's index.
*/
void setWindowIsFullScreen(in unsigned long index, in bool fullscreen);
/**
* Returns the result of a JavaScript operation done within this tab's doc.
*
* @param index The tab's index.
* @param window_index The window's index.
* @param script The script to execute.
* @param result The result, as a string.
* @return true if the script execution ran without errors
*/
boolean runScriptInTabAtIndexInWindow(in unsigned long index,
in unsigned long window_index,
in AUTF8String script,
out AUTF8String result);
};
[scriptable, uuid(45f087af-9c24-4fc6-9325-359382196a4e)]
@ -234,4 +248,18 @@ interface nsIApplescriptTabCallback : nsISupports
* @param window_index The window's index.
*/
void reloadTabAtIndexInWindow(in unsigned long index, in unsigned long window_index);
/**
* Returns the result of a JavaScript operation done within this tab's doc.
*
* @param index The tab's index.
* @param window_index The window's index.
* @param script The script to execute.
* @param result The result, as a string.
* @return true if the script execution ran without errors
*/
bool runScriptInTabAtIndexInWindow(in unsigned long index,
in unsigned long window_index,
in AUTF8String script,
out AUTF8String result);
};

View File

@ -157,6 +157,22 @@ nsApplescriptService::ReloadTabAtIndexInWindow(uint32_t index, uint32_t window_i
return NS_OK;
}
NS_IMETHODIMP
nsApplescriptService::RunScriptInTabAtIndexInWindow(uint32_t index,
uint32_t window_index,
const nsACString& script,
nsACString& result,
bool* ok) {
if (tabCallback) {
return tabCallback->RunScriptInTabAtIndexInWindow(index, window_index, script, result, ok);
}
*ok = false;
result = NULL;
return NS_OK;
}
// ---------
NS_IMETHODIMP
nsApplescriptService::RegisterWindowCallback(nsIApplescriptWindowCallback *callback) {
windowCallback = callback;