OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 /** | 5 /** |
6 * @constructor | 6 * @constructor |
7 * @param {!HTMLSelectElement} selectElement | 7 * @param {!HTMLSelectElement} selectElement |
8 */ | 8 */ |
9 WebInspector.NetworkConditionsSelector = function(selectElement) | 9 WebInspector.NetworkConditionsSelector = function(selectElement) |
10 { | 10 { |
(...skipping 20 matching lines...) Expand all Loading... |
31 var throughputInKbps = conditions.throughput / (1024 / 8); | 31 var throughputInKbps = conditions.throughput / (1024 / 8); |
32 return (throughputInKbps < 1024) ? WebInspector.UIString("%d KB/s", throughp
utInKbps) : WebInspector.UIString("%d MB/s", (throughputInKbps / 1024) | 0); | 32 return (throughputInKbps < 1024) ? WebInspector.UIString("%d KB/s", throughp
utInKbps) : WebInspector.UIString("%d MB/s", (throughputInKbps / 1024) | 0); |
33 } | 33 } |
34 | 34 |
35 /** | 35 /** |
36 * @param {string} value | 36 * @param {string} value |
37 * @return {string} | 37 * @return {string} |
38 */ | 38 */ |
39 WebInspector.NetworkConditionsSelector.throughputValidator = function(value) | 39 WebInspector.NetworkConditionsSelector.throughputValidator = function(value) |
40 { | 40 { |
41 if (!value || (/^[\d]+(\.\d+)?|\.\d+$/.test(value) && value >= 0)) | 41 if (!value || (/^[\d]+(\.\d+)?|\.\d+$/.test(value) && value >= 0 && value <=
10000000)) |
42 return ""; | 42 return ""; |
43 return WebInspector.UIString("Value must be non-negative float"); | 43 return WebInspector.UIString("Value must be non-negative float"); |
44 } | 44 } |
45 | 45 |
46 /** | 46 /** |
47 * @param {string} value | 47 * @param {string} value |
48 * @return {string} | 48 * @return {string} |
49 */ | 49 */ |
50 WebInspector.NetworkConditionsSelector.latencyValidator = function(value) | 50 WebInspector.NetworkConditionsSelector.latencyValidator = function(value) |
51 { | 51 { |
52 if (!value || (/^[\d]+$/.test(value) && value >= 0)) | 52 if (!value || (/^[\d]+$/.test(value) && value >= 0 && value <= 1000000)) |
53 return ""; | 53 return ""; |
54 return WebInspector.UIString("Value must be non-negative integer"); | 54 return WebInspector.UIString("Value must be non-negative integer"); |
55 } | 55 } |
56 | 56 |
57 /** @type {!Array.<!WebInspector.NetworkConditionsProfile>} */ | 57 /** @type {!Array.<!WebInspector.NetworkConditionsProfile>} */ |
58 WebInspector.NetworkConditionsSelector._networkConditionsPresets = [ | 58 WebInspector.NetworkConditionsSelector._networkConditionsPresets = [ |
59 {title: "Offline", value: {throughput: 0 * 1024 / 8, latency: 0}}, | 59 {title: "Offline", value: {throughput: 0 * 1024 / 8, latency: 0}}, |
60 {title: "GPRS", value: {throughput: 50 * 1024 / 8, latency: 500}}, | 60 {title: "GPRS", value: {throughput: 50 * 1024 / 8, latency: 500}}, |
61 {title: "Regular 2G", value: {throughput: 250 * 1024 / 8, latency: 300}}, | 61 {title: "Regular 2G", value: {throughput: 250 * 1024 / 8, latency: 300}}, |
62 {title: "Good 2G", value: {throughput: 450 * 1024 / 8, latency: 150}}, | 62 {title: "Good 2G", value: {throughput: 450 * 1024 / 8, latency: 150}}, |
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
372 if (this._editConditionsListItem) | 372 if (this._editConditionsListItem) |
373 this._editConditionsListItem.classList.remove("hidden"); | 373 this._editConditionsListItem.classList.remove("hidden"); |
374 if (this._editConditionsElement.parentElement) | 374 if (this._editConditionsElement.parentElement) |
375 this._conditionsList.removeChild(this._editConditionsElement); | 375 this._conditionsList.removeChild(this._editConditionsElement); |
376 this._addCustomButton.disabled = false; | 376 this._addCustomButton.disabled = false; |
377 this._addCustomButton.focus(); | 377 this._addCustomButton.focus(); |
378 }, | 378 }, |
379 | 379 |
380 __proto__: WebInspector.VBox.prototype | 380 __proto__: WebInspector.VBox.prototype |
381 } | 381 } |
OLD | NEW |