Changeset 240471 in webkit
- Timestamp:
- Jan 25, 2019 1:27:50 AM (5 years ago)
- Location:
- trunk
- Files:
-
- 20 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r240469 r240471 1 2019-01-25 Devin Rousso <drousso@apple.com> 2 3 Web Inspector: improve invalid Audit/Recording JSON error messages 4 https://bugs.webkit.org/show_bug.cgi?id=193476 5 <rdar://problem/47303659> 6 7 Reviewed by Joseph Pecoraro. 8 9 * inspector/model/auditTestCase.html: 10 * inspector/model/auditTestCase-expected.txt: 11 * inspector/model/auditTestCaseResult-expected.txt: 12 * inspector/model/auditTestGroup.html: 13 * inspector/model/auditTestGroup-expected.txt: 14 * inspector/model/auditTestGroupResult-expected.txt: 15 * inspector/model/recording-expected.txt: 16 1 17 2019-01-24 Devin Rousso <drousso@apple.com> 2 18 -
trunk/LayoutTests/inspector/model/auditTestCase-expected.txt
r237613 r240471 23 23 24 24 -- Running test case: AuditTestCase.fromPayload.validWithInvalidOptionals 25 WARN: Audit Warning: "validWithInvalidOptionals test name" has a non-string "description" value 26 WARN: Audit Warning: "validWithInvalidOptionals test name" is too new to run in this Web Inspector 25 27 { 26 28 "type": "test-case", 27 29 "name": "validWithInvalidOptionals test name", 30 "supports": 2, 28 31 "test": "validWithInvalidOptionals test function" 29 32 } … … 34 37 "name": "validWithValidOptionals test name", 35 38 "description": "validWithValidOptionals test description", 39 "supports": 0, 36 40 "test": "validWithValidOptionals test function" 37 41 } -
trunk/LayoutTests/inspector/model/auditTestCase.html
r237656 r240471 53 53 name: "validWithInvalidOptionals test name", 54 54 description: null, 55 supports: WI.AuditTestBase.Version + 1, 55 56 test: "validWithInvalidOptionals test function", 56 57 }, … … 62 63 name: "validWithValidOptionals test name", 63 64 description: "validWithValidOptionals test description", 65 supports: WI.AuditTestBase.Version - 1, 64 66 test: "validWithValidOptionals test function", 65 67 }, -
trunk/LayoutTests/inspector/model/auditTestCaseResult-expected.txt
r238850 r240471 23 23 24 24 -- Running test case: AuditTestCaseResult.fromPayload.validWithInvalidOptionals 25 WARN: Audit Warning: "validWithInvalidOptionals test result name" has a non-object "data" value 26 WARN: Audit Warning: "validWithInvalidOptionals test result name" has a non-object "metadata" value 27 WARN: Audit Warning: "validWithInvalidOptionals test result name" has a non-string "description" value 25 28 { 26 29 "type": "test-case-result", … … 30 33 31 34 -- Running test case: AuditTestCaseResult.fromPayload.validWithInvalidSubOptionals 35 WARN: Audit Warning: "validWithInvalidSubOptionals test result name" has a non-object "metadata.startTimestamp" value 36 WARN: Audit Warning: "validWithInvalidSubOptionals test result name" has a non-object "metadata.asyncTimestamp" value 37 WARN: Audit Warning: "validWithInvalidSubOptionals test result name" has a non-object "metadata.endTimestamp" value 38 WARN: Audit Warning: "validWithInvalidSubOptionals test result name" has a non-object "metadata.url" value 32 39 { 33 40 "type": "test-case-result", -
trunk/LayoutTests/inspector/model/auditTestGroup-expected.txt
r237613 r240471 35 35 36 36 -- Running test case: AuditTestGroup.fromPayload.validWithInvalidOptionals 37 WARN: Audit Warning: "validWithInvalidOptionals test name" has a non-string "description" value 38 WARN: Audit Warning: "validWithInvalidOptionals test name" is too new to run in this Web Inspector 39 WARN: Audit Warning: "validWithInvalidOptionals group name" has a non-string "description" value 40 WARN: Audit Warning: "validWithInvalidOptionals group name" is too new to run in this Web Inspector 37 41 { 38 42 "type": "test-group", 39 43 "name": "validWithInvalidOptionals group name", 44 "supports": 2, 40 45 "tests": [ 41 46 { 42 47 "type": "test-case", 43 48 "name": "validWithInvalidOptionals test name", 49 "supports": 3, 44 50 "test": "validWithInvalidOptionals test function" 45 51 } … … 52 58 "name": "validWithValidOptionals group name", 53 59 "description": "validWithValidOptionals group description", 60 "supports": 0, 54 61 "tests": [ 55 62 { … … 57 64 "name": "validWithValidOptionals test name", 58 65 "description": "validWithValidOptionals test description", 66 "supports": -1, 59 67 "test": "validWithValidOptionals test function" 60 68 } … … 67 75 "name": "validNested group name", 68 76 "description": "validNested group description", 77 "supports": 0, 69 78 "tests": [ 70 79 { … … 72 81 "name": "validNested nested group name", 73 82 "description": "validNested nested group description", 83 "supports": -1, 74 84 "tests": [ 75 85 { … … 77 87 "name": "validNested nested test name", 78 88 "description": "validNested nested test description", 89 "supports": -2, 79 90 "test": "validNested nested test function" 80 91 } … … 85 96 "name": "validNested test name", 86 97 "description": "validNested test description", 98 "supports": -3, 87 99 "test": "validNested test function" 88 100 } -
trunk/LayoutTests/inspector/model/auditTestGroup.html
r237656 r240471 77 77 name: "validWithInvalidOptionals group name", 78 78 description: null, 79 supports: WI.AuditTestBase.Version + 1, 79 80 tests: [ 80 81 { … … 82 83 name: "validWithInvalidOptionals test name", 83 84 description: null, 85 supports: WI.AuditTestBase.Version + 2, 84 86 test: "validWithInvalidOptionals test function", 85 87 }, … … 93 95 name: "validWithValidOptionals group name", 94 96 description: "validWithValidOptionals group description", 97 supports: WI.AuditTestBase.Version - 1, 95 98 tests: [ 96 99 { … … 98 101 name: "validWithValidOptionals test name", 99 102 description: "validWithValidOptionals test description", 103 supports: WI.AuditTestBase.Version - 2, 100 104 test: "validWithValidOptionals test function", 101 105 }, … … 109 113 name: "validNested group name", 110 114 description: "validNested group description", 115 supports: WI.AuditTestBase.Version - 1, 111 116 tests: [ 112 117 { … … 114 119 name: "validNested nested group name", 115 120 description: "validNested nested group description", 121 supports: WI.AuditTestBase.Version - 2, 116 122 tests: [ 117 123 { … … 119 125 name: "validNested nested test name", 120 126 description: "validNested nested test description", 127 supports: WI.AuditTestBase.Version - 3, 121 128 test: "validNested nested test function", 122 129 }, … … 127 134 name: "validNested test name", 128 135 description: "validNested test description", 136 supports: WI.AuditTestBase.Version - 4, 129 137 test: "validNested test function", 130 138 }, -
trunk/LayoutTests/inspector/model/auditTestGroupResult-expected.txt
r238850 r240471 35 35 36 36 -- Running test case: AuditTestGroupResult.fromPayload.validWithInvalidOptionals 37 WARN: Audit Warning: "validWithInvalidOptionals test result name" has a non-object "data" value 38 WARN: Audit Warning: "validWithInvalidOptionals test result name" has a non-object "metadata" value 39 WARN: Audit Warning: "validWithInvalidOptionals test result name" has a non-string "description" value 40 WARN: Audit Warning: "validWithInvalidOptionals group result name" has a non-string "description" value 37 41 { 38 42 "type": "test-group-result", -
trunk/LayoutTests/inspector/model/recording-expected.txt
r238199 r240471 10 10 11 11 -- Running test case: Recording.fromPayload.emptyObject 12 ERROR: Recording Error: non-number version 12 13 null 13 14 14 15 -- Running test case: Recording.fromPayload.invalidTopLevelMembers 16 ERROR: Recording Error: non-number version 15 17 null 16 18 17 19 -- Running test case: Recording.fromPayload.invalidSubMembers 20 WARN: Recording Warning: unknown type "test" 21 WARN: Recording Warning: non-object initialState.attributes 22 WARN: Recording Warning: non-array initialState.states 23 WARN: Recording Warning: non-array initialState.attributes 24 WARN: Recording Warning: non-string initialState.content 18 25 { 19 26 "version": 1, … … 31 38 32 39 -- Running test case: Recording.fromPayload.invalidFrame 40 WARN: Recording Warning: unknown type "test" 41 WARN: Recording Warning: non-array actions 33 42 { 34 43 "version": 1, … … 59 68 60 69 -- Running test case: Recording.fromPayload.invalidAction 70 WARN: Recording Warning: unknown type "test" 61 71 { 62 72 "version": 1, … … 96 106 97 107 -- Running test case: Recording.fromPayload.invalidActionMembers 108 WARN: Recording Warning: unknown type "test" 109 WARN: Recording Warning: non-number name 110 WARN: Recording Warning: non-array parameters 111 WARN: Recording Warning: non-array swizzleTypes 112 WARN: Recording Warning: non-number trace 98 113 { 99 114 "version": 1, … … 117 132 "actions": [ 118 133 [ 119 null,134 -1, 120 135 [], 121 136 [], … … 133 148 134 149 -- Running test case: Recording.fromPayload.valid 150 WARN: Recording Warning: unknown type "test" 135 151 { 136 152 "version": 1, -
trunk/Source/WebInspectorUI/ChangeLog
r240469 r240471 1 2019-01-25 Devin Rousso <drousso@apple.com> 2 3 Web Inspector: improve invalid Audit/Recording JSON error messages 4 https://bugs.webkit.org/show_bug.cgi?id=193476 5 <rdar://problem/47303659> 6 7 Reviewed by Joseph Pecoraro. 8 9 * UserInterface/Models/AuditTestBase.js: 10 (WI.AuditTestBase): 11 * UserInterface/Models/AuditTestCase.js: 12 (WI.AuditTestCase.async fromPayload): 13 * UserInterface/Models/AuditTestGroup.js: 14 (WI.AuditTestGroup.async fromPayload): 15 * UserInterface/Models/AuditTestCaseResult.js: 16 (WI.AuditTestCaseResult.async fromPayload.checkArray): 17 (WI.AuditTestCaseResult.async fromPayload): 18 * UserInterface/Models/AuditTestGroupResult.js: 19 (WI.AuditTestGroupResult.async fromPayload): 20 * UserInterface/Controllers/AuditManager.js: 21 (WI.AuditManager.synthesizeWarning): Added. 22 (WI.AuditManager.synthesizeError): 23 (WI.AuditManager.prototype.async processJSON): 24 25 * UserInterface/Models/Recording.js: 26 (WI.Recording.fromPayload): 27 (WI.Recording.synthesizeWarning): Added. 28 (WI.Recording.synthesizeError): 29 * UserInterface/Models/RecordingFrame.js: 30 (WI.RecordingFrame.fromPayload): 31 * UserInterface/Models/RecordingAction.js: 32 (WI.RecordingAction.fromPayload): 33 (WI.RecordingAction.prototype.async swizzle): 34 (WI.RecordingAction.prototype.apply): 35 * UserInterface/Controllers/CanvasManager.js: 36 (WI.CanvasManager.prototype.processJSON): 37 38 * Localizations/en.lproj/localizedStrings.js: 39 1 40 2019-01-24 Devin Rousso <drousso@apple.com> 2 41 -
trunk/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js
r240469 r240471 132 132 localizedStrings["Attributes"] = "Attributes"; 133 133 localizedStrings["Audit"] = "Audit"; 134 localizedStrings["Audit error: %s"] = "Audit error: %s"; 134 localizedStrings["Audit Error: %s"] = "Audit Error: %s"; 135 localizedStrings["Audit Warning: %s"] = "Audit Warning: %s"; 135 136 localizedStrings["Audit:"] = "Audit:"; 136 137 localizedStrings["Audits"] = "Audits"; … … 727 728 localizedStrings["Recording"] = "Recording"; 728 729 localizedStrings["Recording %d"] = "Recording %d"; 730 localizedStrings["Recording Error: %s"] = "Recording Error: %s"; 729 731 localizedStrings["Recording Timeline Data"] = "Recording Timeline Data"; 730 localizedStrings["Recording error: %s"] = "Recording error: %s";732 localizedStrings["Recording Warning: %s"] = "Recording Warning: %s"; 731 733 localizedStrings["Recordings"] = "Recordings"; 732 734 localizedStrings["Redirect Response"] = "Redirect Response"; … … 1055 1057 localizedStrings["Yes"] = "Yes"; 1056 1058 localizedStrings["Zoom:"] = "Zoom:"; 1057 localizedStrings["\u0022%s\u0022 is invalid."] = "\u0022%s\u0022 is invalid."; 1059 localizedStrings["\u0022%s\u0022 has a non-array \u0022%s\u0022 value"] = "\u0022%s\u0022 has a non-array \u0022%s\u0022 value"; 1060 localizedStrings["\u0022%s\u0022 has a non-number \u0022%s\u0022 value"] = "\u0022%s\u0022 has a non-number \u0022%s\u0022 value"; 1061 localizedStrings["\u0022%s\u0022 has a non-object \u0022%s\u0022 value"] = "\u0022%s\u0022 has a non-object \u0022%s\u0022 value"; 1062 localizedStrings["\u0022%s\u0022 has a non-string \u0022%s\u0022 value"] = "\u0022%s\u0022 has a non-string \u0022%s\u0022 value"; 1063 localizedStrings["\u0022%s\u0022 has an invalid \u0022%s\u0022 value"] = "\u0022%s\u0022 has an invalid \u0022%s\u0022 value"; 1064 localizedStrings["\u0022%s\u0022 is not valid for %s"] = "\u0022%s\u0022 is not valid for %s"; 1065 localizedStrings["\u0022%s\u0022 is too new to run in this Web Inspector"] = "\u0022%s\u0022 is too new to run in this Web Inspector"; 1066 localizedStrings["\u0022%s\u0022 is too new to run on this inspected page"] = "\u0022%s\u0022 is too new to run on this inspected page"; 1058 1067 localizedStrings["\u0022%s\u0022 must be a %s"] = "\u0022%s\u0022 must be a %s"; 1059 1068 localizedStrings["\u0022%s\u0022 must be an %s"] = "\u0022%s\u0022 must be an %s"; 1060 localizedStrings["\u0022%s\u0022 threw an error ."] = "\u0022%s\u0022 threw an error.";1069 localizedStrings["\u0022%s\u0022 threw an error"] = "\u0022%s\u0022 threw an error"; 1061 1070 localizedStrings["\u201C%s\u201D Event Fired"] = "\u201C%s\u201D Event Fired"; 1062 1071 localizedStrings["\u201C%s\u201D Profile Recorded"] = "\u201C%s\u201D Profile Recorded"; … … 1064 1073 localizedStrings["default"] = "default"; 1065 1074 localizedStrings["for changes to take effect"] = "for changes to take effect"; 1066 localizedStrings["invalid JSON ."] = "invalid JSON.";1075 localizedStrings["invalid JSON"] = "invalid JSON"; 1067 1076 localizedStrings["key"] = "key"; 1068 1077 localizedStrings["line "] = "line "; 1078 localizedStrings["non-array %s"] = "non-array %s"; 1079 localizedStrings["non-integer %s"] = "non-integer %s"; 1080 localizedStrings["non-number %s"] = "non-number %s"; 1081 localizedStrings["non-object %s"] = "non-object %s"; 1082 localizedStrings["non-string %s"] = "non-string %s"; 1069 1083 localizedStrings["originally %s"] = "originally %s"; 1070 1084 localizedStrings["popup"] = "popup"; … … 1075 1089 localizedStrings["times before stopping"] = "times before stopping"; 1076 1090 localizedStrings["toggle"] = "toggle"; 1077 localizedStrings["unsupported version."] = "unsupported version."; 1091 localizedStrings["unknown %s \u0022%s\u0022"] = "unknown %s \u0022%s\u0022"; 1092 localizedStrings["unsupported %s"] = "unsupported %s"; 1078 1093 localizedStrings["value"] = "value"; -
trunk/Source/WebInspectorUI/UserInterface/Controllers/AuditManager.js
r239976 r240471 41 41 } 42 42 43 // Static 44 45 static synthesizeWarning(message) 46 { 47 message = WI.UIString("Audit Warning: %s").format(message); 48 49 if (window.InspectorTest) { 50 console.warn(message); 51 return; 52 } 53 54 let consoleMessage = new WI.ConsoleMessage(WI.mainTarget, WI.ConsoleMessage.MessageSource.Other, WI.ConsoleMessage.MessageLevel.Warning, message); 55 consoleMessage.shouldRevealConsole = true; 56 57 WI.consoleLogViewController.appendConsoleMessage(consoleMessage); 58 } 59 43 60 static synthesizeError(message) 44 61 { 45 let consoleMessage = new WI.ConsoleMessage(WI.mainTarget, WI.ConsoleMessage.MessageSource.Other, WI.ConsoleMessage.MessageLevel.Error, WI.UIString("Audit error: %s").format(message)); 62 message = WI.UIString("Audit Error: %s").format(message); 63 64 if (window.InspectorTest) { 65 console.error(message); 66 return; 67 } 68 69 let consoleMessage = new WI.ConsoleMessage(WI.mainTarget, WI.ConsoleMessage.MessageSource.Other, WI.ConsoleMessage.MessageLevel.Error, message); 46 70 consoleMessage.shouldRevealConsole = true; 47 71 … … 170 194 } 171 195 172 let object = await WI.AuditTestGroup.fromPayload(json) || await WI.AuditTestCase.fromPayload(json); 173 if (!object) { 174 object = await WI.AuditTestGroupResult.fromPayload(json) || await WI.AuditTestCaseResult.fromPayload(json); 175 if (!object) { 176 WI.AuditManager.synthesizeError(WI.UIString("invalid JSON.")); 177 return; 178 } 179 } 196 if (typeof json !== "object" || json === null) { 197 WI.AuditManager.synthesizeError(WI.UIString("invalid JSON")); 198 return; 199 } 200 201 if (json.type !== WI.AuditTestCase.TypeIdentifier || json.type !== WI.AuditTestGroup.TypeIdentifier 202 || json.type !== WI.AuditTestCaseResult.TypeIdentifier || json.type !== WI.AuditTestGroupResult.TypeIdentifier) { 203 WI.AuditManager.synthesizeError(WI.UIString("unknown %s \u0022%s\u0022").format(WI.unlocalizedString("type"), json.type)); 204 return; 205 } 206 207 let object = await WI.AuditTestGroup.fromPayload(json) || await WI.AuditTestCase.fromPayload(json) || await WI.AuditTestGroupResult.fromPayload(json) || await WI.AuditTestCaseResult.fromPayload(json); 208 if (!object) 209 return; 180 210 181 211 if (object instanceof WI.AuditTestBase) { -
trunk/Source/WebInspectorUI/UserInterface/Controllers/CanvasManager.js
r238198 r240471 75 75 } 76 76 77 if (typeof json !== "object" || json === null) { 78 WI.Recording.synthesizeError(WI.UIString("invalid JSON")); 79 return; 80 } 81 77 82 let recording = WI.Recording.fromPayload(json); 78 if (!recording) { 79 WI.Recording.synthesizeError(WI.UIString("unsupported version.")); 80 return; 81 } 83 if (!recording) 84 return; 82 85 83 86 let extensionStart = filename.lastIndexOf("."); -
trunk/Source/WebInspectorUI/UserInterface/Models/AuditTestBase.js
r240469 r240471 44 44 this._supported = true; 45 45 if (typeof this._supports === "number") { 46 if (this._supports > WI.AuditTestBase.Version) 46 if (this._supports > WI.AuditTestBase.Version) { 47 WI.AuditManager.synthesizeWarning(WI.UIString("\u0022%s\u0022 is too new to run in this Web Inspector").format(this.name)); 47 48 this._supported = false; 48 else if (InspectorBackend.domains.Audit && this._supports > InspectorBackend.domains.Audit.VERSION) 49 } else if (InspectorBackend.domains.Audit && this._supports > InspectorBackend.domains.Audit.VERSION) { 50 WI.AuditManager.synthesizeWarning(WI.UIString("\u0022%s\u0022 is too new to run on this inspected page").format(this.name)); 49 51 this._supported = false; 52 } 50 53 } 51 54 -
trunk/Source/WebInspectorUI/UserInterface/Models/AuditTestCase.js
r240469 r240471 42 42 return null; 43 43 44 let {type, name, test, description, supports, disabled} = payload; 45 46 if (type !== WI.AuditTestCase.TypeIdentifier) 47 return null; 48 49 if (typeof name !== "string") 50 return null; 51 52 if (typeof test !== "string") 53 return null; 44 if (payload.type !== WI.AuditTestCase.TypeIdentifier) 45 return null; 46 47 if (typeof payload.name !== "string") { 48 WI.AuditManager.synthesizeError(WI.UIString("\u0022%s\u0022 has a non-string \u0022%s\u0022 value").format(payload.name, WI.unlocalizedString("name"))); 49 return null; 50 } 51 52 if (typeof payload.test !== "string") { 53 WI.AuditManager.synthesizeError(WI.UIString("\u0022%s\u0022 has a non-string \u0022%s\u0022 value").format(payload.name, WI.unlocalizedString("test"))); 54 return null; 55 } 54 56 55 57 let options = {}; 56 if (typeof description === "string") 57 options.description = description; 58 if (typeof supports === "number") 59 options.supports = supports; 60 if (typeof disabled === "boolean") 61 options.disabled = disabled; 62 63 return new WI.AuditTestCase(name, test, options); 58 59 if (typeof payload.description === "string") 60 options.description = payload.description; 61 else if ("description" in payload) 62 WI.AuditManager.synthesizeWarning(WI.UIString("\u0022%s\u0022 has a non-string \u0022%s\u0022 value").format(payload.name, WI.unlocalizedString("description"))); 63 64 if (typeof payload.supports === "number") 65 options.supports = payload.supports; 66 else if ("supports" in payload) 67 WI.AuditManager.synthesizeWarning(WI.UIString("\u0022%s\u0022 has a non-number \u0022%s\u0022 value").format(payload.name, WI.unlocalizedString("supports"))); 68 69 if (typeof payload.disabled === "boolean") 70 options.disabled = payload.disabled; 71 72 return new WI.AuditTestCase(payload.name, payload.test, options); 64 73 } 65 74 -
trunk/Source/WebInspectorUI/UserInterface/Models/AuditTestCaseResult.js
r238850 r240471 49 49 return null; 50 50 51 let {type, name, description, level, data, metadata} = payload; 52 53 if (type !== WI.AuditTestCaseResult.TypeIdentifier) 54 return null; 55 56 if (typeof name !== "string") 57 return null; 58 59 if (!Object.values(WI.AuditTestCaseResult.Level).includes(level)) 60 return null; 61 62 if (typeof data !== "object" || data === null) 63 data = {}; 64 else { 51 if (payload.type !== WI.AuditTestCaseResult.TypeIdentifier) 52 return null; 53 54 if (typeof payload.name !== "string") { 55 WI.AuditManager.synthesizeError(WI.UIString("\u0022%s\u0022 has a non-string \u0022%s\u0022 value").format(payload.name, WI.unlocalizedString("name"))); 56 return null; 57 } 58 59 if (!Object.values(WI.AuditTestCaseResult.Level).includes(payload.level)) { 60 WI.AuditManager.synthesizeError(WI.UIString("\u0022%s\u0022 has an invalid \u0022%s\u0022 value").format(payload.name, WI.unlocalizedString("level"))); 61 return null; 62 } 63 64 if (typeof payload.data !== "object" || payload.data === null) { 65 if ("data" in payload) 66 WI.AuditManager.synthesizeWarning(WI.UIString("\u0022%s\u0022 has a non-object \u0022%s\u0022 value").format(payload.name, WI.unlocalizedString("data"))); 67 payload.data = {}; 68 } else { 65 69 function checkArray(key) { 66 if (! data[key])70 if (!payload.data[key]) 67 71 return; 68 72 69 if (!Array.isArray(data[key])) 70 data[key] = []; 71 72 data[key] = data[key].filter((item) => typeof item === "string"); 73 if (!Array.isArray(payload.data[key])) { 74 WI.AuditManager.synthesizeWarning(WI.UIString("\u0022%s\u0022 has a non-array \u0022%s\u0022 value").format(payload.name, WI.unlocalizedString("data.%s").format(key))); 75 payload.data[key] = []; 76 } 77 78 payload.data[key] = payload.data[key].filter((item) => typeof item === "string"); 73 79 } 74 80 checkArray("domNodes"); … … 77 83 } 78 84 79 if (typeof metadata !== "object" || metadata === null) 80 metadata = {}; 81 else { 82 metadata.startTimestamp = typeof metadata.startTimestamp === "string" ? new Date(metadata.startTimestamp) : null; 83 metadata.asyncTimestamp = typeof metadata.asyncTimestamp === "string" ? new Date(metadata.asyncTimestamp) : null; 84 metadata.endTimestamp = typeof metadata.endTimestamp === "string" ? new Date(metadata.endTimestamp) : null; 85 metadata.url = typeof metadata.url === "string" ? metadata.url : null; 85 if (typeof payload.metadata !== "object" || payload.metadata === null) { 86 if ("metadata" in payload) 87 WI.AuditManager.synthesizeWarning(WI.UIString("\u0022%s\u0022 has a non-object \u0022%s\u0022 value").format(payload.name, WI.unlocalizedString("metadata"))); 88 89 payload.metadata = {}; 90 } else { 91 if (typeof payload.metadata.startTimestamp === "string") 92 payload.metadata.startTimestamp = new Date(payload.metadata.startTimestamp); 93 else { 94 if ("startTimestamp" in payload.metadata) 95 WI.AuditManager.synthesizeWarning(WI.UIString("\u0022%s\u0022 has a non-object \u0022%s\u0022 value").format(payload.name, WI.unlocalizedString("metadata.startTimestamp"))); 96 97 payload.metadata.startTimestamp = null; 98 } 99 100 if (typeof payload.metadata.asyncTimestamp === "string") 101 payload.metadata.asyncTimestamp = new Date(payload.metadata.asyncTimestamp); 102 else { 103 if ("asyncTimestamp" in payload.metadata) 104 WI.AuditManager.synthesizeWarning(WI.UIString("\u0022%s\u0022 has a non-object \u0022%s\u0022 value").format(payload.name, WI.unlocalizedString("metadata.asyncTimestamp"))); 105 106 payload.metadata.asyncTimestamp = null; 107 } 108 109 if (typeof payload.metadata.endTimestamp === "string") 110 payload.metadata.endTimestamp = new Date(payload.metadata.endTimestamp); 111 else { 112 if ("endTimestamp" in payload.metadata) 113 WI.AuditManager.synthesizeWarning(WI.UIString("\u0022%s\u0022 has a non-object \u0022%s\u0022 value").format(payload.name, WI.unlocalizedString("metadata.endTimestamp"))); 114 115 payload.metadata.endTimestamp = null; 116 } 117 118 if (typeof payload.metadata.url !== "string") { 119 if ("url" in payload.metadata) 120 WI.AuditManager.synthesizeWarning(WI.UIString("\u0022%s\u0022 has a non-object \u0022%s\u0022 value").format(payload.name, WI.unlocalizedString("metadata.url"))); 121 122 payload.metadata.url = null; 123 } 86 124 } 87 125 88 126 let options = {}; 89 if (typeof description === "string") 90 options.description = description; 91 if (!isEmptyObject(data)) { 127 128 if (typeof payload.description === "string") 129 options.description = payload.description; 130 else if ("description" in payload) 131 WI.AuditManager.synthesizeWarning(WI.UIString("\u0022%s\u0022 has a non-string \u0022%s\u0022 value").format(payload.name, WI.unlocalizedString("description"))); 132 133 if (!isEmptyObject(payload.data)) { 92 134 options.data = {}; 93 if ( data.domNodes &&data.domNodes.length) {94 if (window.DOMAgent && (! metadata.url ||metadata.url === WI.networkManager.mainFrame.url)) {135 if (payload.data.domNodes && payload.data.domNodes.length) { 136 if (window.DOMAgent && (!payload.metadata.url || payload.metadata.url === WI.networkManager.mainFrame.url)) { 95 137 let documentNode = await new Promise((resolve) => WI.domManager.requestDocument(resolve)); 96 options.resolvedDOMNodes = await Promise.all( data.domNodes.map(async (domNodeString) => {138 options.resolvedDOMNodes = await Promise.all(payload.data.domNodes.map(async (domNodeString) => { 97 139 let nodeId = 0; 98 140 try { … … 103 145 } 104 146 105 options.data.domNodes = data.domNodes; 106 } 107 if (data.domAttributes && data.domAttributes.length) 108 options.data.domAttributes = data.domAttributes; 109 if (data.errors && data.errors.length) 110 options.data.errors = data.errors; 111 } 112 if (!isEmptyObject(metadata)) { 147 options.data.domNodes = payload.data.domNodes; 148 } 149 if (payload.data.domAttributes && payload.data.domAttributes.length) 150 options.data.domAttributes = payload.data.domAttributes; 151 if (payload.data.errors && payload.data.errors.length) 152 options.data.errors = payload.data.errors; 153 } 154 155 if (!isEmptyObject(payload.metadata)) { 113 156 options.metadata = {}; 114 if ( metadata.startTimestamp && !isNaN(metadata.startTimestamp))115 options.metadata.startTimestamp = metadata.startTimestamp;116 if ( metadata.asyncTimestamp && !isNaN(metadata.asyncTimestamp))117 options.metadata.asyncTimestamp = metadata.asyncTimestamp;118 if ( metadata.endTimestamp && !isNaN(metadata.endTimestamp))119 options.metadata.endTimestamp = metadata.endTimestamp;120 if ( metadata.url)121 options.metadata.url = metadata.url;122 } 123 124 return new WI.AuditTestCaseResult( name,level, options);157 if (payload.metadata.startTimestamp && !isNaN(payload.metadata.startTimestamp)) 158 options.metadata.startTimestamp = payload.metadata.startTimestamp; 159 if (payload.metadata.asyncTimestamp && !isNaN(payload.metadata.asyncTimestamp)) 160 options.metadata.asyncTimestamp = payload.metadata.asyncTimestamp; 161 if (payload.metadata.endTimestamp && !isNaN(payload.metadata.endTimestamp)) 162 options.metadata.endTimestamp = payload.metadata.endTimestamp; 163 if (payload.metadata.url) 164 options.metadata.url = payload.metadata.url; 165 } 166 167 return new WI.AuditTestCaseResult(payload.name, payload.level, options); 125 168 } 126 169 -
trunk/Source/WebInspectorUI/UserInterface/Models/AuditTestGroup.js
r240469 r240471 67 67 return null; 68 68 69 let {type, name, tests, description, supports, disabled} = payload; 70 71 if (type !== WI.AuditTestGroup.TypeIdentifier) 72 return null; 73 74 if (typeof name !== "string") 75 return null; 76 77 if (!Array.isArray(tests)) 78 return null; 79 80 tests = await Promise.all(tests.map(async (test) => { 69 if (payload.type !== WI.AuditTestGroup.TypeIdentifier) 70 return null; 71 72 if (typeof payload.name !== "string") { 73 WI.AuditManager.synthesizeError(WI.UIString("\u0022%s\u0022 has a non-string \u0022%s\u0022 value").format(payload.name, WI.unlocalizedString("name"))); 74 return null; 75 } 76 77 if (!Array.isArray(payload.tests)) { 78 WI.AuditManager.synthesizeError(WI.UIString("\u0022%s\u0022 has a non-array \u0022%s\u0022 value").format(payload.name, WI.unlocalizedString("tests"))); 79 return null; 80 } 81 82 let tests = await Promise.all(payload.tests.map(async (test) => { 81 83 let testCase = await WI.AuditTestCase.fromPayload(test); 82 84 if (testCase) … … 94 96 95 97 let options = {}; 96 if (typeof description === "string") 97 options.description = description; 98 if (typeof supports === "number") 99 options.supports = supports; 100 if (typeof disabled === "boolean") 101 options.disabled = disabled; 102 103 return new WI.AuditTestGroup(name, tests, options); 98 99 if (typeof payload.description === "string") 100 options.description = payload.description; 101 else if ("description" in payload) 102 WI.AuditManager.synthesizeWarning(WI.UIString("\u0022%s\u0022 has a non-string \u0022%s\u0022 value").format(payload.name, WI.unlocalizedString("description"))); 103 104 if (typeof payload.supports === "number") 105 options.supports = payload.supports; 106 else if ("supports" in payload) 107 WI.AuditManager.synthesizeWarning(WI.UIString("\u0022%s\u0022 has a non-number \u0022%s\u0022 value").format(payload.name, WI.unlocalizedString("supports"))); 108 109 if (typeof payload.disabled === "boolean") 110 options.disabled = payload.disabled; 111 112 return new WI.AuditTestGroup(payload.name, tests, options); 104 113 } 105 114 -
trunk/Source/WebInspectorUI/UserInterface/Models/AuditTestGroupResult.js
r237656 r240471 42 42 return null; 43 43 44 let {type, name, description, results} = payload; 45 46 if (type !== WI.AuditTestGroupResult.TypeIdentifier) 44 if (payload.type !== WI.AuditTestGroupResult.TypeIdentifier) 47 45 return null; 48 46 49 if (typeof name !== "string") 47 if (typeof payload.name !== "string") { 48 WI.AuditManager.synthesizeError(WI.UIString("\u0022%s\u0022 has a non-string \u0022%s\u0022 value").format(payload.name, WI.unlocalizedString("name"))); 50 49 return null; 50 } 51 51 52 if (!Array.isArray(results)) 52 if (!Array.isArray(payload.results)) { 53 WI.AuditManager.synthesizeError(WI.UIString("\u0022%s\u0022 has a non-array \u0022%s\u0022 value").format(payload.name, WI.unlocalizedString("results"))); 53 54 return null; 55 } 54 56 55 results = await Promise.all(results.map(async (test) => {57 let results = await Promise.all(payload.results.map(async (test) => { 56 58 let testCaseResult = await WI.AuditTestCaseResult.fromPayload(test); 57 59 if (testCaseResult) … … 69 71 70 72 let options = {}; 71 if (typeof description === "string")72 options.description = description;73 73 74 return new WI.AuditTestGroupResult(name, results, options); 74 if (typeof payload.description === "string") 75 options.description = payload.description; 76 else if ("description" in payload) 77 WI.AuditManager.synthesizeWarning(WI.UIString("\u0022%s\u0022 has a non-string \u0022%s\u0022 value").format(payload.name, WI.unlocalizedString("description"))); 78 79 return new WI.AuditTestGroupResult(payload.name, results, options); 75 80 } 76 81 -
trunk/Source/WebInspectorUI/UserInterface/Models/Recording.js
r240318 r240471 52 52 return null; 53 53 54 if (isNaN(payload.version) || payload.version <= 0 || payload.version > WI.Recording.Version) 54 if (typeof payload.version !== "number") { 55 WI.Recording.synthesizeError(WI.UIString("non-number %s").format(WI.unlocalizedString("version"))); 55 56 return null; 57 } 58 59 if (payload.version < 1 || payload.version > WI.Recording.Version) { 60 WI.Recording.synthesizeError(WI.UIString("unsupported %s").format(WI.unlocalizedString("version"))); 61 return null; 62 } 63 64 if (parseInt(payload.version) !== payload.version) { 65 WI.Recording.synthesizeWarning(WI.UIString("non-integer %s").format(WI.unlocalizedString("version"))); 66 payload.version = parseInt(payload.version); 67 } 56 68 57 69 let type = null; … … 67 79 break; 68 80 default: 81 WI.Recording.synthesizeWarning(WI.UIString("unknown %s \u0022%s\u0022").format(WI.unlocalizedString("type"), payload.type)); 69 82 type = String(payload.type); 70 83 break; 71 84 } 72 85 73 if (typeof payload.initialState !== "object" || payload.initialState === null) 86 if (typeof payload.initialState !== "object" || payload.initialState === null) { 87 if ("initialState" in payload) 88 WI.Recording.synthesizeWarning(WI.UIString("non-object %s").format(WI.unlocalizedString("initialState"))); 89 74 90 payload.initialState = {}; 75 if (typeof payload.initialState.attributes !== "object" || payload.initialState.attributes === null) 91 } 92 93 if (typeof payload.initialState.attributes !== "object" || payload.initialState.attributes === null) { 94 if ("attributes" in payload.initialState) 95 WI.Recording.synthesizeWarning(WI.UIString("non-object %s").format(WI.unlocalizedString("initialState.attributes"))); 96 76 97 payload.initialState.attributes = {}; 98 } 99 77 100 if (!Array.isArray(payload.initialState.states) || payload.initialState.states.some((item) => typeof item !== "object" || item === null)) { 101 if ("states" in payload.initialState) 102 WI.Recording.synthesizeWarning(WI.UIString("non-array %s").format(WI.unlocalizedString("initialState.states"))); 103 78 104 payload.initialState.states = []; 79 105 … … 85 111 } 86 112 } 87 if (!Array.isArray(payload.initialState.parameters)) 113 114 if (!Array.isArray(payload.initialState.parameters)) { 115 if ("parameters" in payload.initialState) 116 WI.Recording.synthesizeWarning(WI.UIString("non-array %s").format(WI.unlocalizedString("initialState.attributes"))); 117 88 118 payload.initialState.parameters = []; 89 if (typeof payload.initialState.content !== "string") 119 } 120 121 if (typeof payload.initialState.content !== "string") { 122 if ("content" in payload.initialState) 123 WI.Recording.synthesizeWarning(WI.UIString("non-string %s").format(WI.unlocalizedString("initialState.content"))); 124 90 125 payload.initialState.content = ""; 91 92 if (!Array.isArray(payload.frames)) 126 } 127 128 if (!Array.isArray(payload.frames)) { 129 if ("frames" in payload) 130 WI.Recording.synthesizeWarning(WI.UIString("non-array %s").format(WI.unlocalizedString("frames"))); 131 93 132 payload.frames = []; 94 95 if (!Array.isArray(payload.data)) 133 } 134 135 if (!Array.isArray(payload.data)) { 136 if ("data" in payload) 137 WI.Recording.synthesizeWarning(WI.UIString("non-array %s").format(WI.unlocalizedString("data"))); 138 96 139 payload.data = []; 140 } 97 141 98 142 if (!frames) … … 151 195 } 152 196 197 static synthesizeWarning(message) 198 { 199 message = WI.UIString("Recording Warning: %s").format(message); 200 201 if (window.InspectorTest) { 202 console.warn(message); 203 return; 204 } 205 206 let consoleMessage = new WI.ConsoleMessage(WI.mainTarget, WI.ConsoleMessage.MessageSource.Other, WI.ConsoleMessage.MessageLevel.Warning, message); 207 consoleMessage.shouldRevealConsole = true; 208 209 WI.consoleLogViewController.appendConsoleMessage(consoleMessage); 210 } 211 153 212 static synthesizeError(message) 154 213 { 155 const target = WI.mainTarget; 156 const source = WI.ConsoleMessage.MessageSource.Other; 157 const level = WI.ConsoleMessage.MessageLevel.Error; 158 let consoleMessage = new WI.ConsoleMessage(target, source, level, WI.UIString("Recording error: %s").format(message)); 214 message = WI.UIString("Recording Error: %s").format(message); 215 216 if (window.InspectorTest) { 217 console.error(message); 218 return; 219 } 220 221 let consoleMessage = new WI.ConsoleMessage(WI.mainTarget, WI.ConsoleMessage.MessageSource.Other, WI.ConsoleMessage.MessageLevel.Error, message); 159 222 consoleMessage.shouldRevealConsole = true; 160 223 -
trunk/Source/WebInspectorUI/UserInterface/Models/RecordingAction.js
r238743 r240471 64 64 payload = []; 65 65 66 if (isNaN(payload[0])) 66 if (typeof payload[0] !== "number") { 67 if (payload.length > 0) 68 WI.Recording.synthesizeWarning(WI.UIString("non-number %s").format(WI.unlocalizedString("name"))); 69 67 70 payload[0] = -1; 68 69 if (!Array.isArray(payload[1])) 71 } 72 73 if (!Array.isArray(payload[1])) { 74 if (payload.length > 1) 75 WI.Recording.synthesizeWarning(WI.UIString("non-array %s").format(WI.unlocalizedString("parameters"))); 76 70 77 payload[1] = []; 71 72 if (!Array.isArray(payload[2])) 78 } 79 80 if (!Array.isArray(payload[2])) { 81 if (payload.length > 2) 82 WI.Recording.synthesizeWarning(WI.UIString("non-array %s").format(WI.unlocalizedString("swizzleTypes"))); 83 73 84 payload[2] = []; 74 75 if (isNaN(payload[3]) || (!payload[3] && payload[3] !== 0)) { 85 } 86 87 if (typeof payload[3] !== "number" || isNaN(payload[3]) || (!payload[3] && payload[3] !== 0)) { 76 88 // COMPATIBILITY (iOS 12.1): "trace" was sent as an array of call frames instead of a single call stack 77 if (!Array.isArray(payload[3])) 89 if (!Array.isArray(payload[3])) { 90 if (payload.length > 3) 91 WI.Recording.synthesizeWarning(WI.UIString("non-number %s").format(WI.unlocalizedString("trace"))); 92 78 93 payload[3] = []; 79 } 80 81 if (payload.length >= 5 && isNaN(payload[4])) 94 } 95 } 96 97 if (typeof payload[4] !== "number" || isNaN(payload[4])) { 98 if (payload.length > 4) 99 WI.Recording.synthesizeWarning(WI.UIString("non-number %s").format(WI.unlocalizedString("snapshot"))); 100 82 101 payload[4] = -1; 102 } 83 103 84 104 return new WI.RecordingAction(...payload); … … 311 331 this.markInvalid(); 312 332 313 WI.Recording.synthesize Error(WI.UIString("\u0022%s\u0022 is invalid.").format(name));333 WI.Recording.synthesizeWarning(WI.UIString("\u0022%s\u0022 is not valid for %s").format(name, prototype.constructor.name)); 314 334 } 315 335 } … … 361 381 this.markInvalid(); 362 382 363 WI.Recording.synthesize Error(WI.UIString("\u0022%s\u0022 threw an error.").format(this._name));383 WI.Recording.synthesizeWarning(WI.UIString("\u0022%s\u0022 threw an error").format(this._name)); 364 384 } 365 385 } -
trunk/Source/WebInspectorUI/UserInterface/Models/RecordingFrame.js
r224389 r240471 40 40 payload = {}; 41 41 42 if (!Array.isArray(payload.actions)) 42 if (!Array.isArray(payload.actions)) { 43 if ("actions" in payload) 44 WI.Recording.synthesizeWarning(WI.UIString("non-array %s").format(WI.unlocalizedString("actions"))); 45 43 46 payload.actions = []; 47 } 44 48 45 49 let actions = payload.actions.map(WI.RecordingAction.fromPayload);
Note: See TracChangeset
for help on using the changeset viewer.