Skip to content

Commit

Permalink
Merge pull request #129 from IBMa/detatch-window
Browse files Browse the repository at this point in the history
Retool so that works with FF too
  • Loading branch information
tombrunet authored Jun 18, 2020
2 parents 93eae62 + 224625e commit 218f23a
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 20 deletions.
9 changes: 9 additions & 0 deletions accessibility-checker-extension/src/ts/background/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,15 @@ BackgroundMessaging.addListener("DAP_SCAN_TAB_COMPLETE", async (message: any) =>
return true;
});

BackgroundMessaging.addListener("TAB_INFO", async (message: any) => {
return await new Promise((resolve, _reject) => {
chrome.tabs.get(message.tabId, async function(tab: any) {
//chrome.tabs.get({ 'active': true, 'lastFocusedWindow': true }, async function (tabs) {
resolve(tab);
});
});
});

BackgroundMessaging.addListener("DAP_Rulesets", async (message: any) => {


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,29 +127,26 @@ export default class DevToolsPanelApp extends React.Component<IPanelProps, IPane
var self = this;

// to fix when undocked get tab id using chrome.devtools.inspectedWindow.tabId
// and get url using chrome.tabs.get
// and get url using chrome.tabs.get via message "TAB_INFO"
let thisTabId = chrome.devtools.inspectedWindow.tabId;
chrome.tabs.get(thisTabId, async function(tab) {
var url = tab.url;
var title = tab.title
if (tab.id && tab.url && tab.id && tab.title) {
let rulesets = await PanelMessaging.sendToBackground("DAP_Rulesets", { tabId: tab.id })
url = tab.url;
title = tab.title;
if (!self.state.listenerRegistered) {
PanelMessaging.addListener("TAB_UPDATED", async message => {
if (message.tabId === self.state.tabId && message.status === "loading") {
if (message.tabUrl && message.tabUrl != self.state.tabURL) {
self.setState({ report: null, tabURL: message.tabUrl });
}
let tab = await PanelMessaging.sendToBackground("TAB_INFO", {tabId: thisTabId });

if (tab.id && tab.url && tab.id && tab.title) {
let rulesets = await PanelMessaging.sendToBackground("DAP_Rulesets", { tabId: tab.id })

if (!self.state.listenerRegistered) {
PanelMessaging.addListener("TAB_UPDATED", async message => {
if (message.tabId === self.state.tabId && message.status === "loading") {
if (message.tabUrl && message.tabUrl != self.state.tabURL) {
self.setState({ report: null, tabURL: message.tabUrl });
}
});
PanelMessaging.addListener("DAP_SCAN_COMPLETE", self.onReport.bind(self));
PanelMessaging.sendToBackground("DAP_CACHED", { tabId: tab.id })
}
self.setState({ rulesets: rulesets, listenerRegistered: true, tabURL: url, tabId: tab.id, tabTitle: title });
}
});
PanelMessaging.addListener("DAP_SCAN_COMPLETE", self.onReport.bind(self));
PanelMessaging.sendToBackground("DAP_CACHED", { tabId: tab.id })
}
});
self.setState({ rulesets: rulesets, listenerRegistered: true, tabURL: tab.url, tabId: tab.id, tabTitle: tab.title });
}
}

async startScan() {
Expand Down

0 comments on commit 218f23a

Please sign in to comment.