1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
content / browser / resources / net / network_errors_listing.js [blame]
// Copyright 2015 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import {$} from 'chrome://resources/js/util.js';
/**
* Generate the page content.
* @param {Array<Object>} errorCodes Error codes array consisting of a
* numerical error ID and error code string.
*/
function listErrorCodes(errorCodes) {
const errorPageUrl = 'chrome://network-error/';
const errorCodesList = document.createElement('ul');
for (let i = 0; i < errorCodes.length; i++) {
const listEl = document.createElement('li');
const errorCodeLinkEl = document.createElement('a');
errorCodeLinkEl.href = errorPageUrl + errorCodes[i].errorId;
errorCodeLinkEl.textContent =
errorCodes[i].errorCode + ' (' + errorCodes[i].errorId + ')';
listEl.appendChild(errorCodeLinkEl);
errorCodesList.appendChild(listEl);
}
$('pages').appendChild(errorCodesList);
}
function initialize() {
const xhr = new XMLHttpRequest();
xhr.open('GET', 'network-error-data.json');
xhr.addEventListener('load', function(e) {
if (xhr.status === 200) {
try {
const data = JSON.parse(xhr.responseText);
listErrorCodes(data['errorCodes']);
} catch (e) {
$('pages').innerText = 'Could not parse the error codes data. ' +
'Try reloading the page.';
}
}
});
xhr.send();
}
document.addEventListener('DOMContentLoaded', initialize);