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..b1cb5567743ba763f5d744bf320309f247b1154e |
--- /dev/null |
+++ b/content/browser/resources/net/network_errors_listing.js |
@@ -0,0 +1,45 @@ |
+// 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'; |
+ |
+ /** |
+ * Generate the page content. |
+ * @param {Array.<Object>} errorCodes Error codes array consisting of a |
+ * numerical error ID and error code string. |
+ */ |
+ function listErrorCodes(errorCodes) { |
+ var errorPageURL = 'chrome://network-error/'; |
Dan Beam
2015/12/01 04:24:17
nit: errorPageUrl
edwardjung
2015/12/01 12:30:08
Done.
|
+ 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 xhr = new XMLHttpRequest(); |
+ xhr.open('GET', 'network-error-data.json', true); |
Dan Beam
2015/12/01 04:24:17
nit: do you need the async param (true)?
edwardjung
2015/12/01 12:30:08
Removed, I'm still in the mindset of developing fo
|
+ xhr.addEventListener('load', function(e) { |
+ if (xhr.status === 200) { |
+ var data = JSON.parse(xhr.responseText); |
Dan Beam
2015/12/01 04:24:17
do you want to handle the semi-likely case that th
edwardjung
2015/12/01 12:30:08
Done
|
+ listErrorCodes(data['errorCodes']); |
+ } |
+ }); |
Dan Beam
2015/12/01 04:24:17
indent off
edwardjung
2015/12/01 12:30:08
Done.
|
+ xhr.send(null); |
Dan Beam
2015/12/01 04:24:17
why not just send()?
edwardjung
2015/12/01 12:30:08
Done
|
+ } |
+ |
+ return { |
+ initialize: initialize |
+ }; |
+}); |
+ |
+document.addEventListener('DOMContentLoaded', errorCodes.initialize); |