Index: content/browser/resources/net/network_errors_listing.js |
diff --git a/content/browser/resources/net/network_errors_listing.js b/content/browser/resources/net/network_errors_listing.js |
new file mode 100644 |
index 0000000000000000000000000000000000000000..61a46d2ea3f9f300cc5b70628aa9aa8a71363fae |
--- /dev/null |
+++ b/content/browser/resources/net/network_errors_listing.js |
@@ -0,0 +1,44 @@ |
+// Copyright 2015 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+cr.define('errorCodes', function() { |
+ 'use strict'; |
+ |
+ function requestData() { |
+ var xhr = new XMLHttpRequest(); |
+ xhr.open('GET', 'network-error-data.json', false); |
Dan Beam
2015/11/24 20:08:20
don't do synchronous XHR
edwardjung
2015/11/24 21:42:12
Done.
|
+ xhr.send(null); |
+ if (xhr.status === 200) { |
+ return JSON.parse(xhr.responseText); |
+ } |
Dan Beam
2015/11/24 20:08:20
nit: no curlies
edwardjung
2015/11/24 21:42:12
Done.
|
+ return []; |
+ } |
+ |
Dan Beam
2015/11/24 20:08:20
/** @param {Array} errorCode
preferably with Arra
edwardjung
2015/11/24 21:42:12
Done.
|
+ function listErrorCodes(errorCodes) { |
+ var errorPageURL = 'chrome://network-error/'; |
+ var errorCodesList = document.createElement('ul'); |
+ for (var i = 0; i < errorCodes.length; i++) { |
+ var listEl = document.createElement('li'); |
+ var 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() { |
+ var data = requestData(); |
Dan Beam
2015/11/24 20:08:20
why are you making a method to only use it once?
edwardjung
2015/11/24 21:42:12
Removed.
|
+ $('pages').textContent = ''; |
Dan Beam
2015/11/24 20:08:20
what is this doing? clearing #pages?
edwardjung
2015/11/24 21:42:12
Removed.
|
+ listErrorCodes(data['errorCodes']); |
+ } |
+ |
+ return { |
+ initialize: initialize |
+ }; |
+}); |
+ |
+document.addEventListener('DOMContentLoaded', errorCodes.initialize); |