-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BDE-240: Inject content script into the page to detect disconnection
- Loading branch information
Showing
3 changed files
with
41 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
(async () => { | ||
let connected; | ||
|
||
try { | ||
const response = await fetch('/nuxeo/json/cmis'); | ||
// Some pages can return an HTML page with 404 message on it. | ||
// We should validate that the response is a json object. | ||
await response.json(); | ||
connected = response.ok; | ||
} catch (error) { | ||
connected = false; | ||
} | ||
|
||
if (!connected) { | ||
await chrome.runtime.sendMessage({ | ||
extension: 'nuxeo-web-extension', | ||
component: 'serverConnector', | ||
action: 'disconnect', | ||
params: [] | ||
}); | ||
} | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters