refactor: implement ajax() in tests using native fetch instead of jQuery (#32579)
This commit is contained in:
parent
7032be660d
commit
9d054755d6
13 changed files with 116 additions and 160 deletions
29
spec/fixtures/pages/basic-auth.html
vendored
29
spec/fixtures/pages/basic-auth.html
vendored
|
@ -1,22 +1,21 @@
|
|||
<html>
|
||||
<body>
|
||||
<script src="../../static/jquery-2.0.3.min.js"></script>
|
||||
<script type="text/javascript" charset="utf-8">
|
||||
var ipcRenderer = require('electron').ipcRenderer;
|
||||
var port = location.search.substr("?port=".length);
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: "http://127.0.0.1:" + port,
|
||||
headers: {
|
||||
"Authorization": "Basic " + btoa("test:test")
|
||||
},
|
||||
success: function(result) {
|
||||
ipcRenderer.sendToHost(result);
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
const { ipcRenderer } = require('electron');
|
||||
const url = new URL(location.href);
|
||||
const port = url.searchParams.get('port');
|
||||
(async () => {
|
||||
try {
|
||||
const response = await fetch(`http://127.0.0.1:${port}`, {
|
||||
headers: {
|
||||
'Authorization': `Basic ${btoa('test:test')}`
|
||||
}
|
||||
});
|
||||
ipcRenderer.sendToHost(await response.text());
|
||||
} catch (error) {
|
||||
ipcRenderer.sendToHost(error);
|
||||
},
|
||||
});
|
||||
}
|
||||
})();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue