Skip to content

Commit

Permalink
skeleton for AppleScript-JavaScript interface (#549)
Browse files Browse the repository at this point in the history
  • Loading branch information
classilla committed Mar 17, 2019
1 parent b360417 commit 8868813
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 0 deletions.
5 changes: 5 additions & 0 deletions browser/components/nsBrowserGlue.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

Expand Down
28 changes: 28 additions & 0 deletions toolkit/components/applescript/public/nsIApplescriptService.idl
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down Expand Up @@ -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);
};
16 changes: 16 additions & 0 deletions toolkit/components/applescript/src/nsApplescriptService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 8868813

Please sign in to comment.