| OLD | NEW |
| 1 /* This Source Code Form is subject to the terms of the Mozilla Public | 1 /* This Source Code Form is subject to the terms of the Mozilla Public |
| 2 * License, v. 2.0. If a copy of the MPL was not distributed with this | 2 * License, v. 2.0. If a copy of the MPL was not distributed with this |
| 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
| 4 | 4 |
| 5 (function() | 5 (function() |
| 6 { | 6 { |
| 7 var version = null; | 7 var version = null; |
| 8 function doPoll() | 8 function doPoll() |
| 9 { | 9 { |
| 10 var request = new XMLHttpRequest(); | 10 fetch(chrome.extension.getURL("devenvVersion__")) |
| 11 request.open("GET", chrome.extension.getURL("devenvVersion__")); | 11 .then(function(response) |
| 12 request.addEventListener("load", function() | 12 { |
| 13 { | 13 return response.text(); |
| 14 if (version == null) | 14 }) |
| 15 version = request.responseText; | 15 .then(function(text) |
| 16 { |
| 17 if (version == null) |
| 18 version = text; |
| 16 | 19 |
| 17 if (request.responseText != version) | 20 if (text != version) |
| 18 chrome.runtime.reload(); | 21 chrome.runtime.reload(); |
| 19 else | 22 else |
| 20 window.setTimeout(doPoll, 5000); | 23 window.setTimeout(doPoll, 5000); |
| 21 }, false); | 24 }); |
| 22 request.send(null); | |
| 23 } | 25 } |
| 24 | 26 |
| 25 // Delay first poll to prevent reloading again immediately after a reload | 27 // Delay first poll to prevent reloading again immediately after a reload |
| 26 doPoll(); | 28 doPoll(); |
| 27 })(); | 29 })(); |
| OLD | NEW |