Changeset 248890 in webkit
- Timestamp:
- Aug 19, 2019 9:22:03 PM (5 years ago)
- Location:
- trunk
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r248876 r248890 1 2019-08-19 Devin Rousso <drousso@apple.com> 2 3 Web Inspector: have more aggressive checks for dataURLs provided to `console.screenshot` 4 https://bugs.webkit.org/show_bug.cgi?id=200747 5 6 Reviewed by Joseph Pecoraro. 7 8 * inspector/console/console-screenshot.html: 9 * inspector/console/console-screenshot-expected.txt: 10 1 11 2019-08-19 Alexey Shvayka <shvaikalesh@gmail.com> 2 12 -
trunk/LayoutTests/inspector/console/console-screenshot-expected.txt
r248736 r248890 8 8 CONSOLE MESSAGE: [object ImageBitmap] 9 9 CONSOLE MESSAGE: [object CanvasRenderingContext2D] 10 CONSOLE MESSAGE: Viewport 10 11 CONSOLE MESSAGE: data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAIAAAACCAYAAABytg0kAAAAAXNSR0IArs4c6QAAABNJREFUCB1j/M/AAEQMDEwgAgQAHxcCAmtAm/sAAAAASUVORK5CYII= 11 CONSOLE MESSAGE: Viewport 12 CONSOLE MESSAGE: data:fake/mime 13 CONSOLE MESSAGE: data:image/png;base64,<INVALID> 14 CONSOLE MESSAGE: data:image/png;a1=b2;base64, 12 15 CONSOLE MESSAGE: Viewport 13 16 CONSOLE MESSAGE: Viewport … … 48 51 49 52 -- Running test case: console.screenshot.Node.DetachedNonScreenshotable 50 PASS: Could not capture screenshot53 PASS: Error: Could not capture screenshot 51 54 52 55 -- Running test case: console.screenshot.ImageData … … 68 71 PASS: The image height should be 2px. 69 72 70 -- Running test case: console.screenshot.String.Base64.Valid 73 -- Running test case: console.screenshot.String.Valid 74 PASS: The added message should be an image. 75 PASS: The image should not be empty. 76 PASS: The image width should be greater than 2px. 77 PASS: The image height should be greater than 2px. 78 79 -- Running test case: console.screenshot.String.dataURL.Valid 71 80 PASS: The added message should be an image. 72 81 PASS: The image should not be empty. … … 74 83 PASS: The image height should be 2px. 75 84 76 -- Running test case: console.screenshot.String. Base64.NoContent85 -- Running test case: console.screenshot.String.dataURL.InvalidMIME 77 86 PASS: The added message should be an image. 78 87 PASS: The image should not be empty. 79 PASS: The image width should be greater than 2px. 80 PASS: The image height should be greater than 2px. 88 PASS: The image should not load. 81 89 82 -- Running test case: console.screenshot.String.Base64.Invalid 90 -- Running test case: console.screenshot.String.dataURL.InvalidContent 91 PASS: The added message should be an image. 92 PASS: The image should not be empty. 93 PASS: The image should not load. 94 95 -- Running test case: console.screenshot.String.dataURL.InvalidNoContent 96 PASS: The added message should be an image. 97 PASS: The image should not be empty. 98 PASS: The image should not load. 99 100 -- Running test case: console.screenshot.String.dataURL.ValidNoContent 83 101 PASS: The added message should be an image. 84 102 PASS: The image should not be empty. -
trunk/LayoutTests/inspector/console/console-screenshot.html
r248736 r248890 77 77 78 78 if (message.level === WI.ConsoleMessage.MessageLevel.Error) { 79 InspectorTest.expectThat(shouldError, message.messageText);79 InspectorTest.expectThat(shouldError, "Error: " + message.messageText); 80 80 return; 81 81 } … … 84 84 InspectorTest.expectNotEqual(message.messageText, "data:", "The image should not be empty."); 85 85 86 let img = await WI.ImageUtilities.promisifyLoad(message.messageText); 87 if (shouldCaptureViewport) { 88 InspectorTest.expectGreaterThan(img.width, 2, "The image width should be greater than 2px."); 89 InspectorTest.expectGreaterThan(img.height, 2, "The image height should be greater than 2px."); 90 } else { 91 InspectorTest.expectEqual(img.width, 2, "The image width should be 2px."); 92 InspectorTest.expectEqual(img.height, 2, "The image height should be 2px."); 86 try { 87 let image = new Image; 88 await new Promise((resolve, reject) => { 89 image.addEventListener("load", resolve); 90 image.addEventListener("error", reject); 91 image.src = message.messageText; 92 }); 93 94 if (shouldCaptureViewport) { 95 InspectorTest.expectGreaterThan(image.width, 2, "The image width should be greater than 2px."); 96 InspectorTest.expectGreaterThan(image.height, 2, "The image height should be greater than 2px."); 97 } else { 98 InspectorTest.expectEqual(image.width, 2, "The image width should be 2px."); 99 InspectorTest.expectEqual(image.height, 2, "The image height should be 2px."); 100 } 101 } catch { 102 InspectorTest.expectThat(shouldError, "The image should not load."); 93 103 } 94 104 }, … … 150 160 151 161 addTest({ 152 name: "console.screenshot.String.Base64.Valid", 162 name: "console.screenshot.String.Valid", 163 expression: `console.screenshot("test")`, 164 shouldCaptureViewport: true, 165 }); 166 167 addTest({ 168 name: "console.screenshot.String.dataURL.Valid", 153 169 expression: `console.screenshot("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAIAAAACCAYAAABytg0kAAAAAXNSR0IArs4c6QAAABNJREFUCB1j/M/AAEQMDEwgAgQAHxcCAmtAm/sAAAAASUVORK5CYII=")`, // 2x2 red square 154 170 }); 155 171 156 172 addTest({ 157 name: "console.screenshot.String.Base64.NoContent", 173 name: "console.screenshot.String.dataURL.InvalidMIME", 174 expression: `console.screenshot("data:fake/mime")`, 175 shouldError: true, 176 }); 177 178 addTest({ 179 name: "console.screenshot.String.dataURL.InvalidContent", 180 expression: `console.screenshot("data:image/png;base64,<INVALID>")`, 181 shouldError: true, 182 }); 183 184 addTest({ 185 name: "console.screenshot.String.dataURL.InvalidNoContent", 158 186 expression: `console.screenshot("data:image/png;a1=b2;base64,")`, 159 should CaptureViewport: true,160 }); 161 162 addTest({ 163 name: "console.screenshot.String. Base64.Invalid",164 expression: `console.screenshot(" invalid")`,187 shouldError: true, 188 }); 189 190 addTest({ 191 name: "console.screenshot.String.dataURL.ValidNoContent", 192 expression: `console.screenshot("data:")`, 165 193 shouldCaptureViewport: true, 166 194 }); -
trunk/Source/WebCore/ChangeLog
r248886 r248890 1 2019-08-19 Devin Rousso <drousso@apple.com> 2 3 Web Inspector: have more aggressive checks for dataURLs provided to `console.screenshot` 4 https://bugs.webkit.org/show_bug.cgi?id=200747 5 6 Reviewed by Joseph Pecoraro. 7 8 Always send any /data:*+/ strings to the frontend and have it render there. If that doesn't 9 work, have the frontend "spoof" an error message look and feel. 10 11 Test: inspector/console/console-screenshot.html 12 13 * page/PageConsoleClient.cpp: 14 (WebCore::PageConsoleClient::screenshot): 15 1 16 2019-08-19 Jer Noble <jer.noble@apple.com> 2 17 -
trunk/Source/WebCore/page/PageConsoleClient.cpp
r248846 r248890 65 65 #include <JavaScriptCore/ConsoleMessage.h> 66 66 #include <JavaScriptCore/JSCInlines.h> 67 #include <JavaScriptCore/RegularExpression.h>68 67 #include <JavaScriptCore/ScriptArguments.h> 69 68 #include <JavaScriptCore/ScriptCallStack.h> … … 388 387 } else { 389 388 String base64; 390 if (possibleTarget.getString(state, base64)) { 391 JSC::Yarr::RegularExpression regex("^data:image/(?:[^;]+;)+base64,.+$"_s, JSC::Yarr::TextCaseSensitivity::TextCaseInsensitive); 392 if (regex.match(base64) != -1) { 393 target = possibleTarget; 394 dataURL = base64; 395 } 389 if (possibleTarget.getString(state, base64) && base64.startsWithIgnoringASCIICase("data:"_s) && base64.length() > 5) { 390 target = possibleTarget; 391 dataURL = base64; 396 392 } 397 393 } -
trunk/Source/WebInspectorUI/ChangeLog
r248889 r248890 1 2019-08-19 Devin Rousso <drousso@apple.com> 2 3 Web Inspector: have more aggressive checks for dataURLs provided to `console.screenshot` 4 https://bugs.webkit.org/show_bug.cgi?id=200747 5 6 Reviewed by Joseph Pecoraro. 7 8 Always send any /data:*+/ strings to the frontend and have it render there. If that doesn't 9 work, have the frontend "spoof" an error message look and feel. 10 11 * UserInterface/Views/ConsoleMessageView.js: 12 (WI.ConsoleMessageView.prototype._appendMessageTextAndArguments): 13 14 * Localizations/en.lproj/localizedStrings.js: 15 1 16 2019-08-19 Nikita Vasilyev <nvasilyev@apple.com> 2 17 -
trunk/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js
r248773 r248890 297 297 localizedStrings["Copy Table"] = "Copy Table"; 298 298 localizedStrings["Copy as cURL"] = "Copy as cURL"; 299 localizedStrings["Could not capture screenshot"] = "Could not capture screenshot"; 299 300 localizedStrings["Could not fetch properties. Object may no longer exist."] = "Could not fetch properties. Object may no longer exist."; 300 301 localizedStrings["Count"] = "Count"; -
trunk/Source/WebInspectorUI/UserInterface/Views/ConsoleMessageView.js
r248766 r248890 306 306 case WI.ConsoleMessage.MessageType.Image: { 307 307 if (this._message.level === WI.ConsoleMessage.MessageLevel.Log) { 308 let divider = null; 309 308 310 if (this._message.parameters.length > 1) { 309 311 this._appendFormattedArguments(element, this._message.parameters.slice(1)); 310 312 311 element.appendChild(document.createElement("hr"));313 divider = element.appendChild(document.createElement("hr")); 312 314 } 313 315 … … 318 320 319 321 if (this._message.messageText) { 320 let img = element.appendChild(document.createElement("img"));322 let img = document.createElement("img"); 321 323 img.classList.add("show-grid"); 322 324 img.src = this._message.messageText; … … 327 329 else 328 330 img.height = img.height / window.devicePixelRatio; 331 element.appendChild(img); 332 }); 333 img.addEventListener("error", (event) => { 334 this._element.setAttribute("data-labelprefix", WI.UIString("Error: ")); 335 this._element.classList.add("console-error-level"); 336 this._element.classList.remove("console-log-level"); 337 338 if (divider) { 339 while (divider.nextSibling) 340 divider.nextSibling.remove(); 341 } else 342 element.removeChildren(); 343 344 let args = [WI.UIString("Could not capture screenshot"), this._message.messageText]; 345 if (this._extraParameters) 346 args = args.concat(this._extraParameters); 347 this._appendFormattedArguments(element, args); 329 348 }); 330 349 } … … 333 352 334 353 if (this._message.level === WI.ConsoleMessage.MessageLevel.Error) { 335 let args = [this._message.messageText]; 354 let args = []; 355 if (this._message.messageText === "Could not capture screenshot") 356 args.push(WI.UIString("Could not capture screenshot")); 357 else 358 args.push(this._message.messageText); 336 359 if (this._extraParameters) 337 360 args = args.concat(this._extraParameters);
Note: See TracChangeset
for help on using the changeset viewer.