Diff
Modified: trunk/LayoutTests/ChangeLog (247811 => 247812)
--- trunk/LayoutTests/ChangeLog 2019-07-25 02:09:42 UTC (rev 247811)
+++ trunk/LayoutTests/ChangeLog 2019-07-25 02:25:05 UTC (rev 247812)
@@ -1,3 +1,13 @@
+2019-07-24 Devin Rousso <[email protected]>
+
+ Web Inspector: support `console.screenshot` with ImageData and ImageBitmap
+ https://bugs.webkit.org/show_bug.cgi?id=199304
+
+ Reviewed by Joseph Pecoraro.
+
+ * inspector/console/console-screenshot.html:
+ * inspector/console/console-screenshot-expected.txt:
+
2019-07-24 Youenn Fablet <[email protected]>
Disable speculative loading if cache is not to be used for the load
Modified: trunk/LayoutTests/inspector/console/console-screenshot-expected.txt (247811 => 247812)
--- trunk/LayoutTests/inspector/console/console-screenshot-expected.txt 2019-07-25 02:09:42 UTC (rev 247811)
+++ trunk/LayoutTests/inspector/console/console-screenshot-expected.txt 2019-07-25 02:25:05 UTC (rev 247812)
@@ -1,6 +1,8 @@
CONSOLE MESSAGE: [object HTMLDivElement]
CONSOLE MESSAGE: [object HTMLDivElement]
CONSOLE MESSAGE: [object HTMLDivElement]
+CONSOLE MESSAGE: [object ImageData]
+CONSOLE MESSAGE: [object ImageBitmap]
CONSOLE MESSAGE: [object CanvasRenderingContext2D]
CONSOLE MESSAGE: Viewport
CONSOLE MESSAGE: Viewport
@@ -23,6 +25,18 @@
-- Running test case: console.screenshot.Node.DetachedNonScreenshotable
PASS: Could not capture screenshot
+-- Running test case: console.screenshot.ImageData
+PASS: The added message should be an image.
+PASS: The image should not be empty.
+PASS: The image width should be 2px.
+PASS: The image height should be 2px.
+
+-- Running test case: console.screenshot.ImageBitmap
+PASS: The added message should be an image.
+PASS: The image should not be empty.
+PASS: The image width should be 2px.
+PASS: The image height should be 2px.
+
-- Running test case: console.screenshot.CanvasRenderingContext2D
PASS: The added message should be an image.
PASS: The image should not be empty.
Modified: trunk/LayoutTests/inspector/console/console-screenshot.html (247811 => 247812)
--- trunk/LayoutTests/inspector/console/console-screenshot.html 2019-07-25 02:09:42 UTC (rev 247811)
+++ trunk/LayoutTests/inspector/console/console-screenshot.html 2019-07-25 02:25:05 UTC (rev 247812)
@@ -11,6 +11,16 @@
return div;
}
+function testImageBitmap() {
+ // 2x2 red square
+ let image = document.createElement("img");
+ image.src = ""
+ image.addEventListener("load", async (event) => {
+ let imageBitmap = await createImageBitmap(image);
+ console.screenshot(imageBitmap);
+ });
+}
+
function createCanvas2DTest() {
let canvas = document.createElement("canvas");
canvas.width = 2;
@@ -83,6 +93,30 @@
});
addTest({
+ name: "console.screenshot.ImageData",
+ _expression_: `console.screenshot(new ImageData(2, 2))`,
+ async imageMessageAddedCallback(message) {
+ InspectorTest.expectNotEqual(message.messageText, "data:", "The image should not be empty.");
+
+ let img = await WI.ImageUtilities.promisifyLoad(message.messageText);
+ InspectorTest.expectEqual(img.width, 2, "The image width should be 2px.");
+ InspectorTest.expectEqual(img.height, 2, "The image height should be 2px.");
+ },
+ });
+
+ addTest({
+ name: "console.screenshot.ImageBitmap",
+ _expression_: `testImageBitmap()`,
+ async imageMessageAddedCallback(message) {
+ InspectorTest.expectNotEqual(message.messageText, "data:", "The image should not be empty.");
+
+ let img = await WI.ImageUtilities.promisifyLoad(message.messageText);
+ InspectorTest.expectEqual(img.width, 2, "The image width should be 2px.");
+ InspectorTest.expectEqual(img.height, 2, "The image height should be 2px.");
+ },
+ });
+
+ addTest({
name: "console.screenshot.CanvasRenderingContext2D",
_expression_: `console.screenshot(createCanvas2DTest())`,
async imageMessageAddedCallback(message) {
Modified: trunk/Source/WebCore/ChangeLog (247811 => 247812)
--- trunk/Source/WebCore/ChangeLog 2019-07-25 02:09:42 UTC (rev 247811)
+++ trunk/Source/WebCore/ChangeLog 2019-07-25 02:25:05 UTC (rev 247812)
@@ -1,5 +1,17 @@
2019-07-24 Devin Rousso <[email protected]>
+ Web Inspector: support `console.screenshot` with ImageData and ImageBitmap
+ https://bugs.webkit.org/show_bug.cgi?id=199304
+
+ Reviewed by Joseph Pecoraro.
+
+ Test: inspector/console/console-screenshot.html
+
+ * page/PageConsoleClient.cpp:
+ (WebCore::PageConsoleClient::screenshot):
+
+2019-07-24 Devin Rousso <[email protected]>
+
Web Inspector: REGRESSION: Overlay: highlighting a ::before/::after shows the node info of the parent instead
https://bugs.webkit.org/show_bug.cgi?id=200051
Modified: trunk/Source/WebCore/page/PageConsoleClient.cpp (247811 => 247812)
--- trunk/Source/WebCore/page/PageConsoleClient.cpp 2019-07-25 02:09:42 UTC (rev 247811)
+++ trunk/Source/WebCore/page/PageConsoleClient.cpp 2019-07-25 02:25:05 UTC (rev 247812)
@@ -36,8 +36,10 @@
#include "Frame.h"
#include "FrameSnapshotting.h"
#include "HTMLCanvasElement.h"
+#include "ImageBitmap.h"
#include "ImageBitmapRenderingContext.h"
#include "ImageBuffer.h"
+#include "ImageData.h"
#include "InspectorController.h"
#include "InspectorInstrumentation.h"
#include "IntRect.h"
@@ -44,7 +46,9 @@
#include "JSCanvasRenderingContext2D.h"
#include "JSExecState.h"
#include "JSHTMLCanvasElement.h"
+#include "JSImageBitmap.h"
#include "JSImageBitmapRenderingContext.h"
+#include "JSImageData.h"
#include "JSNode.h"
#include "JSOffscreenCanvas.h"
#include "Node.h"
@@ -284,6 +288,22 @@
if (auto snapshot = WebCore::snapshotNode(m_page.mainFrame(), *node))
dataURL = snapshot->toDataURL("image/png"_s, WTF::nullopt, PreserveResolution::Yes);
}
+ } else if (auto* imageData = JSImageData::toWrapped(state->vm(), possibleTarget)) {
+ target = possibleTarget;
+ if (UNLIKELY(InspectorInstrumentation::hasFrontends())) {
+ auto sourceSize = imageData->size();
+ if (auto imageBuffer = ImageBuffer::create(sourceSize, RenderingMode::Unaccelerated)) {
+ IntRect sourceRect(IntPoint(), sourceSize);
+ imageBuffer->putByteArray(*imageData->data(), AlphaPremultiplication::Unpremultiplied, sourceSize, sourceRect, IntPoint());
+ dataURL = imageBuffer->toDataURL("image/png"_s, WTF::nullopt, PreserveResolution::Yes);
+ }
+ }
+ } else if (auto* imageBitmap = JSImageBitmap::toWrapped(state->vm(), possibleTarget)) {
+ target = possibleTarget;
+ if (UNLIKELY(InspectorInstrumentation::hasFrontends())) {
+ if (auto* imageBuffer = imageBitmap->buffer())
+ dataURL = imageBuffer->toDataURL("image/png"_s, WTF::nullopt, PreserveResolution::Yes);
+ }
} else if (auto* context = canvasRenderingContext(state->vm(), possibleTarget)) {
auto& canvas = context->canvasBase();
if (is<HTMLCanvasElement>(canvas)) {