Skip to content

Commit c685159

Browse files
committed
warn the user when he tries to select a target in an invalid tab
1 parent 006d41d commit c685159

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

packages/selenium-ide/src/neo/IO/SideeX/find-select.js

+11-3
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,21 @@ export function find(target) {
5252
}
5353

5454
export function select(type, rect) {
55+
const tabConnectionFailure = () => {
56+
ModalState.showAlert({
57+
title: "Can't connect to tab",
58+
description: "Make sure the tab begins with `http://`, or try to refresh the tab.",
59+
confirmLabel: "Close"
60+
});
61+
UiState.setSelectingTarget(false);
62+
};
5563
UiState.setSelectingTarget(!UiState.isSelectingTarget);
5664
if (!UiState.isSelectingTarget) {
5765
browser.tabs.query({
5866
active: true,
5967
windowId: window.contentWindowId
6068
}).then(function(tabs) {
61-
browser.tabs.sendMessage(tabs[0].id, {selectMode: true, selecting: false});
69+
browser.tabs.sendMessage(tabs[0].id, {selectMode: true, selecting: false}).catch(tabConnectionFailure);
6270
}).catch(function(reason) {
6371
console.log(reason);
6472
});
@@ -73,9 +81,9 @@ export function select(type, rect) {
7381
UiState.setSelectingTarget(false);
7482
} else {
7583
if (type === TargetTypes.LOCATOR) {
76-
browser.tabs.sendMessage(tabs[0].id, {selectMode: true, selecting: true, element: true});
84+
browser.tabs.sendMessage(tabs[0].id, {selectMode: true, selecting: true, element: true}).catch(tabConnectionFailure);
7785
} else if (type === TargetTypes.REGION) {
78-
browser.tabs.sendMessage(tabs[0].id, {selectMode: true, selecting: true, region: true, rect: new Region(rect).toJS()});
86+
browser.tabs.sendMessage(tabs[0].id, {selectMode: true, selecting: true, region: true, rect: new Region(rect).toJS()}).catch(tabConnectionFailure);
7987
}
8088
}
8189
});

0 commit comments

Comments
 (0)