#552: fix <<current tab>>

This commit is contained in:
Cameron Kaiser 2019-05-05 16:11:38 -07:00
parent 23f3034604
commit aaa5809fd3
2 changed files with 15 additions and 1 deletions

View File

@ -942,7 +942,14 @@ BrowserGlue.prototype = {
},
getCurrentTabInWindow : function(index, tab_index) {
let win = this.getWindow(index);
return win.content;
if (win != null) {
let tab = win.content;
if (tab != null) {
tab_index.value = win.gBrowser.tabContainer.selectedIndex;
return tab;
}
}
return null;
},
createTabAtIndexInWindow : function(index, window_index) {
let win = this.getWindow(window_index);

View File

@ -578,6 +578,9 @@ static BOOL didInit = NO;
return nil;
}
#if DEBUG
fprintf(stderr, "AppleScript: scriptTab: %i\n", tabIndex);
#endif
return [GeckoTab tabWithIndex:tabIndex andContentWindow:contentWindow andWindow:self];
}
@ -885,6 +888,7 @@ static BOOL didInit = NO;
}
- (NSString*)handleRunJavaScriptCommand:(NSScriptCommand*)command {
NS_WARNING("AppleScript: runJavaScript");
nsCOMPtr<nsIApplescriptService> applescriptService(do_GetService("@mozilla.org/applescript-service;1"));
if (applescriptService) {
NSDictionary *args = [command evaluatedArguments];
@ -896,6 +900,9 @@ static BOOL didInit = NO;
s.Assign([script UTF8String]);
r.Truncate();
#if DEBUG
fprintf(stderr, "AppleScript: run script: win %i tab %i\n", [mWindow orderedIndex], mIndex);
#endif
if (NS_SUCCEEDED(applescriptService->RunScriptInTabAtIndexInWindow(mIndex,
[mWindow orderedIndex],
s, r, &ok))) {