Explorar o código

added support for tabs.create

Gildas %!s(int64=5) %!d(string=hai) anos
pai
achega
9742386cc7
Modificáronse 2 ficheiros con 4 adicións e 2 borrados
  1. 1 1
      extension/core/bg/business.js
  2. 3 1
      extension/core/bg/tabs.js

+ 1 - 1
extension/core/bg/business.js

@@ -172,7 +172,7 @@ singlefile.extension.core.bg.business = (() => {
 			if (!taskInfo.tab.id) {
 				let scriptsInjected;
 				try {
-					const tab = await tabs.create({ url: taskInfo.tab.url, active: false });
+					const tab = await tabs.createAndWait({ url: taskInfo.tab.url, active: false });
 					taskInfo.tab.id = taskInfo.options.tabId = tab.id;
 					taskInfo.tab.index = taskInfo.options.tabIndex = tab.index;
 					ui.onStart(taskInfo.tab.id, INJECT_SCRIPTS_STEP);

+ 3 - 1
extension/core/bg/tabs.js

@@ -37,7 +37,8 @@ singlefile.extension.core.bg.tabs = (() => {
 			const tabs = await browser.tabs.query(options);
 			return tabs.sort((tab1, tab2) => tab1.index - tab2.index);
 		},
-		create: async createProperties => {
+		create: createProperties => browser.tabs.create(createProperties),
+		createAndWait: async createProperties => {
 			const tab = await browser.tabs.create(createProperties);
 			return new Promise((resolve, reject) => {
 				browser.tabs.onUpdated.addListener(onTabUpdated);
@@ -58,6 +59,7 @@ singlefile.extension.core.bg.tabs = (() => {
 			});
 		},
 		sendMessage: (tabId, message, options) => browser.tabs.sendMessage(tabId, message, options),
+		update: (tabId, updateProperties) => browser.tabs.update(tabId, updateProperties),
 		remove: tabId => browser.tabs.remove(tabId),
 		promptValue: async promptMessage => {
 			const tabs = await browser.tabs.query({ currentWindow: true, active: true });