REGRESSION (r192098): Content missing after copy and paste to Notes App on retina...
authorbfulgham@apple.com <bfulgham@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 16 May 2016 17:35:30 +0000 (17:35 +0000)
committerbfulgham@apple.com <bfulgham@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 16 May 2016 17:35:30 +0000 (17:35 +0000)
https://bugs.webkit.org/show_bug.cgi?id=157630
<rdar://problem/25277577>

Reviewed by Simon Fraser.

Source/WebCore:

Tested by http/tests/images/hidpi-srcset-copy.html

The code to create a WebArchive (or other representation) of a webpage was using the 'src' attribute of
the image element, which might be changed to reflect the optimal image dimensions for a specific
display. Instead, we should use the 'imageSourceURL' method of the Element class so we get the correct
'original' image URL in our cached resources.

* editing/cocoa/HTMLConverter.mm:
(HTMLConverter::_processElement): Use 'imageSourceURL', rather than getting the raw 'src' attribute.
* html/HTMLImageElement.cpp:
(WebCore::HTMLImageElement::addSubresourceAttributeURLs): Ditto.

Tools:

Update test infrastructure to support checking the number of images in the pasteboard.

* DumpRenderTree/TestRunner.cpp:
(imageCountInGeneralPasteboardCallback): Added.
(TestRunner::staticFunctions):
* DumpRenderTree/TestRunner.h:
* DumpRenderTree/mac/TestRunnerMac.mm:
(TestRunner::imageCountInGeneralPasteboard): Added.
* DumpRenderTree/win/TestRunnerWin.cpp:
(TestRunner::imageCountInGeneralPasteboard): Added stub method.
* WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl:
* WebKitTestRunner/InjectedBundle/InjectedBundle.cpp:
(WTR::InjectedBundle::imageCountInGeneralPasteboard): Added.
* WebKitTestRunner/InjectedBundle/InjectedBundle.h:
* WebKitTestRunner/InjectedBundle/TestRunner.cpp:
(WTR::TestRunner::imageCountInGeneralPasteboard): Added.
* WebKitTestRunner/InjectedBundle/TestRunner.h:
* WebKitTestRunner/TestController.cpp:
(WTR::TestController::imageCountInGeneralPasteboard): Added stub implementation.
* WebKitTestRunner/TestController.h:
* WebKitTestRunner/TestInvocation.cpp:
(WTR::TestInvocation::didReceiveSynchronousMessageFromInjectedBundle): Handle copy message.
* WebKitTestRunner/cocoa/TestControllerCocoa.mm:
(WTR::TestController::imageCountInGeneralPasteboard): Added.

LayoutTests:

* http/tests/images/hidpi-srcset-copy-expected.txt: Added.
* http/tests/images/hidpi-srcset-copy.html: Added.
* http/tests/resources/img-srcset: Added.
* http/tests/resources/img-srcset/image1-620x442.jpg: Added.
* http/tests/resources/img-srcset/image2-1024x731.jpg: Added.
* http/tests/resources/img-srcset/image2-1400x1000.jpg: Added.
* http/tests/resources/img-srcset/image2-300x214.jpg: Added.
* http/tests/resources/img-srcset/image2-620x442.jpg: Added.
* http/tests/resources/img-srcset/image2-840x600.jpg: Added.
* http/tests/resources/img-srcset/image3-250x178.jpg: Added.
* http/tests/resources/img-srcset/image3-615x438.jpg: Added.
* http/tests/resources/img-srcset/image3-620x440.jpg: Added.
* http/tests/resources/img-srcset/image3-700x498.jpg: Added.
* http/tests/resources/img-srcset/image3-840x598.jpg: Added.
* http/tests/resources/img-srcset/image3.jpg: Added.
* http/tests/resources/img-srcset/image4-1024x612.jpg: Added.
* http/tests/resources/img-srcset/image4-300x179.jpg: Added.
* http/tests/resources/img-srcset/image4-620x370.jpg: Added.
* http/tests/resources/img-srcset/image4-768x459.jpg: Added.
* http/tests/resources/img-srcset/image4-840x502.jpg: Added.
* http/tests/resources/img-srcset/image4-940x560.jpg: Added.
* platform/efl/TestExpectations: No pasteboard implementation. Skip.
* platform/gtk/TestExpectations: Ditto.
* platform/win/TestExpectations: Ditto.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@200945 268f45cc-cd09-0410-ab3c-d52691b4dbfc

41 files changed:
LayoutTests/ChangeLog
LayoutTests/http/tests/images/hidpi-srcset-copy-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/images/hidpi-srcset-copy.html [new file with mode: 0644]
LayoutTests/http/tests/resources/img-srcset/image1-620x442.jpg [new file with mode: 0644]
LayoutTests/http/tests/resources/img-srcset/image2-1024x731.jpg [new file with mode: 0644]
LayoutTests/http/tests/resources/img-srcset/image2-1400x1000.jpg [new file with mode: 0644]
LayoutTests/http/tests/resources/img-srcset/image2-300x214.jpg [new file with mode: 0644]
LayoutTests/http/tests/resources/img-srcset/image2-620x442.jpg [new file with mode: 0644]
LayoutTests/http/tests/resources/img-srcset/image2-840x600.jpg [new file with mode: 0644]
LayoutTests/http/tests/resources/img-srcset/image3-250x178.jpg [new file with mode: 0644]
LayoutTests/http/tests/resources/img-srcset/image3-615x438.jpg [new file with mode: 0644]
LayoutTests/http/tests/resources/img-srcset/image3-620x440.jpg [new file with mode: 0644]
LayoutTests/http/tests/resources/img-srcset/image3-700x498.jpg [new file with mode: 0644]
LayoutTests/http/tests/resources/img-srcset/image3-840x598.jpg [new file with mode: 0644]
LayoutTests/http/tests/resources/img-srcset/image3.jpg [new file with mode: 0644]
LayoutTests/http/tests/resources/img-srcset/image4-1024x612.jpg [new file with mode: 0644]
LayoutTests/http/tests/resources/img-srcset/image4-300x179.jpg [new file with mode: 0644]
LayoutTests/http/tests/resources/img-srcset/image4-620x370.jpg [new file with mode: 0644]
LayoutTests/http/tests/resources/img-srcset/image4-768x459.jpg [new file with mode: 0644]
LayoutTests/http/tests/resources/img-srcset/image4-840x502.jpg [new file with mode: 0644]
LayoutTests/http/tests/resources/img-srcset/image4-940x560.jpg [new file with mode: 0644]
LayoutTests/platform/efl/TestExpectations
LayoutTests/platform/gtk/TestExpectations
LayoutTests/platform/win/TestExpectations
Source/WebCore/ChangeLog
Source/WebCore/editing/cocoa/HTMLConverter.mm
Source/WebCore/html/HTMLImageElement.cpp
Tools/ChangeLog
Tools/DumpRenderTree/TestRunner.cpp
Tools/DumpRenderTree/TestRunner.h
Tools/DumpRenderTree/mac/TestRunnerMac.mm
Tools/DumpRenderTree/win/TestRunnerWin.cpp
Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl
Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp
Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.h
Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp
Tools/WebKitTestRunner/InjectedBundle/TestRunner.h
Tools/WebKitTestRunner/TestController.cpp
Tools/WebKitTestRunner/TestController.h
Tools/WebKitTestRunner/TestInvocation.cpp
Tools/WebKitTestRunner/cocoa/TestControllerCocoa.mm

index 83f68d8..ee526dc 100644 (file)
@@ -1,3 +1,36 @@
+2016-05-16  Brent Fulgham  <bfulgham@apple.com>
+
+        REGRESSION (r192098): Content missing after copy and paste to Notes App on retina displays
+        https://bugs.webkit.org/show_bug.cgi?id=157630
+        <rdar://problem/25277577>
+
+        Reviewed by Simon Fraser.
+
+        * http/tests/images/hidpi-srcset-copy-expected.txt: Added.
+        * http/tests/images/hidpi-srcset-copy.html: Added.
+        * http/tests/resources/img-srcset: Added.
+        * http/tests/resources/img-srcset/image1-620x442.jpg: Added.
+        * http/tests/resources/img-srcset/image2-1024x731.jpg: Added.
+        * http/tests/resources/img-srcset/image2-1400x1000.jpg: Added.
+        * http/tests/resources/img-srcset/image2-300x214.jpg: Added.
+        * http/tests/resources/img-srcset/image2-620x442.jpg: Added.
+        * http/tests/resources/img-srcset/image2-840x600.jpg: Added.
+        * http/tests/resources/img-srcset/image3-250x178.jpg: Added.
+        * http/tests/resources/img-srcset/image3-615x438.jpg: Added.
+        * http/tests/resources/img-srcset/image3-620x440.jpg: Added.
+        * http/tests/resources/img-srcset/image3-700x498.jpg: Added.
+        * http/tests/resources/img-srcset/image3-840x598.jpg: Added.
+        * http/tests/resources/img-srcset/image3.jpg: Added.
+        * http/tests/resources/img-srcset/image4-1024x612.jpg: Added.
+        * http/tests/resources/img-srcset/image4-300x179.jpg: Added.
+        * http/tests/resources/img-srcset/image4-620x370.jpg: Added.
+        * http/tests/resources/img-srcset/image4-768x459.jpg: Added.
+        * http/tests/resources/img-srcset/image4-840x502.jpg: Added.
+        * http/tests/resources/img-srcset/image4-940x560.jpg: Added.
+        * platform/efl/TestExpectations: No pasteboard implementation. Skip.
+        * platform/gtk/TestExpectations: Ditto.
+        * platform/win/TestExpectations: Ditto.
+
 2016-05-16  Joanmarie Diggs  <jdiggs@igalia.com>
 
         [GTK] Unreviewed gardening
diff --git a/LayoutTests/http/tests/images/hidpi-srcset-copy-expected.txt b/LayoutTests/http/tests/images/hidpi-srcset-copy-expected.txt
new file mode 100644 (file)
index 0000000..b1a4f3f
--- /dev/null
@@ -0,0 +1,24 @@
+Tests that we get the correct number of images when copying under different display resolutions.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS successfullyParsed is true
+
+TEST COMPLETE
+PASS Found all 4 images at 1x Resolution.
+PASS Found all 4 images at 2x Resolution.
+PASS Found all 4 images at 3x Resolution.
+Image 1
+
+
+Image 2
+
+
+Image 3
+
+
+Image 4
+
+
+
diff --git a/LayoutTests/http/tests/images/hidpi-srcset-copy.html b/LayoutTests/http/tests/images/hidpi-srcset-copy.html
new file mode 100644 (file)
index 0000000..cd67f4e
--- /dev/null
@@ -0,0 +1,83 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src="../../../resources/js-test-pre.js"></script>
+<script type="text/javascript">
+    description("Tests that we get the correct number of images when copying under different display resolutions.");
+
+    var pixelRatio = 1;
+
+    if (window.testRunner) {
+        testRunner.dumpAsText(true);
+        testRunner.waitUntilDone();
+    }
+
+    function doCopy()
+    {
+        document.execCommand("selectAll", true);
+        document.execCommand("copy");
+    }
+
+    function checkCount()
+    {
+        var imageCount = testRunner.imageCountInGeneralPasteboard();
+        if (imageCount == 4)
+            testPassed("Found all 4 images at " + pixelRatio + "x Resolution.");
+        else
+            testFailed("Only found " + imageCount + " images at " + pixelRatio + "x Resolution.");
+    }
+
+    function doTest()
+    {
+        doCopy();
+        checkCount();
+        if (pixelRatio < 3) {
+            pixelRatio = pixelRatio + 1;
+            testRunner.setBackingScaleFactor(pixelRatio, doTest);
+        } else {
+            setTimeout(function() { testRunner.notifyDone(); }, 0);
+        }
+    }
+
+    function runTests()
+    {
+        if (window.testRunner)
+            testRunner.setBackingScaleFactor(pixelRatio, doTest);        
+    }
+</script>
+</head>
+<body onLoad="runTests()">
+    <div id="images">
+        <p>Image 1</p>
+        <img src="http://127.0.0.1:8000/resources/img-srcset/image1-620x442.jpg">
+        <p>Image 2</p>
+        <img src="http://127.0.0.1:8000/resources/img-srcset/image2-1024x731.jpg"
+            srcset="http://127.0.0.1:8000/resources/img-srcset/image2-300x214.jpg 300w,
+                http://127.0.0.1:8000/resources/img-srcset/image2-1024x731.jpg 1024w,
+                http://127.0.0.1:8000/resources/img-srcset/image2-620x442.jpg 620w,
+                http://127.0.0.1:8000/resources/img-srcset/image2-840x600.jpg 840w,
+                http://127.0.0.1:8000/resources/img-srcset/image2-1400x1000.jpg 1400w"
+            sizes="(max-width: 1024px) 100vw, 1024px">
+        <p>Image 3</p>
+        <img src="http://127.0.0.1:8000/resources/img-srcset/image3-700x498.jpg"
+            srcset="http://127.0.0.1:8000/resources/img-srcset/image3-250x178.jpg 250w,
+                http://127.0.0.1:8000/resources/img-srcset/image3-700x498.jpg 700w, 
+                http://127.0.0.1:8000/resources/img-srcset/image3-620x440.jpg 620w,
+                http://127.0.0.1:8000/resources/img-srcset/image3-615x438.jpg 615w,
+                http://127.0.0.1:8000/resources/img-srcset/image3-840x598.jpg 840w,
+                http://127.0.0.1:8000/resources/img-srcset/image3.jpg 1403w"
+            sizes="(max-width: 700px) 100vw, 700px">
+        <p>Image 4</p>
+        <img src="http://127.0.0.1:8000/resources/img-srcset/image4-1024x612.jpg"
+            srcset="http://127.0.0.1:8000/resources/img-srcset/image4-300x179.jpg 300w,
+                http://127.0.0.1:8000/resources/img-srcset/image4-1024x612.jpg 1024w,
+                http://127.0.0.1:8000/resources/img-srcset/image4-620x370.jpg 620w,
+                http://127.0.0.1:8000/resources/img-srcset/image4-840x502.jpg 840w,
+                http://127.0.0.1:8000/resources/img-srcset/image4-940x560.jpg 940w,
+                http://127.0.0.1:8000/resources/img-srcset/image4-768x459.jpg 768w"
+            sizes="(max-width: 1024px) 100vw, 1024px">
+    </div>
+    <div id="console"></div>
+</body>
+<script src="../../../resources/js-test-post.js"></script>
+</html>
\ No newline at end of file
diff --git a/LayoutTests/http/tests/resources/img-srcset/image1-620x442.jpg b/LayoutTests/http/tests/resources/img-srcset/image1-620x442.jpg
new file mode 100644 (file)
index 0000000..e91464c
Binary files /dev/null and b/LayoutTests/http/tests/resources/img-srcset/image1-620x442.jpg differ
diff --git a/LayoutTests/http/tests/resources/img-srcset/image2-1024x731.jpg b/LayoutTests/http/tests/resources/img-srcset/image2-1024x731.jpg
new file mode 100644 (file)
index 0000000..713f7d5
Binary files /dev/null and b/LayoutTests/http/tests/resources/img-srcset/image2-1024x731.jpg differ
diff --git a/LayoutTests/http/tests/resources/img-srcset/image2-1400x1000.jpg b/LayoutTests/http/tests/resources/img-srcset/image2-1400x1000.jpg
new file mode 100644 (file)
index 0000000..98c0ae1
Binary files /dev/null and b/LayoutTests/http/tests/resources/img-srcset/image2-1400x1000.jpg differ
diff --git a/LayoutTests/http/tests/resources/img-srcset/image2-300x214.jpg b/LayoutTests/http/tests/resources/img-srcset/image2-300x214.jpg
new file mode 100644 (file)
index 0000000..cb1e583
Binary files /dev/null and b/LayoutTests/http/tests/resources/img-srcset/image2-300x214.jpg differ
diff --git a/LayoutTests/http/tests/resources/img-srcset/image2-620x442.jpg b/LayoutTests/http/tests/resources/img-srcset/image2-620x442.jpg
new file mode 100644 (file)
index 0000000..33015ac
Binary files /dev/null and b/LayoutTests/http/tests/resources/img-srcset/image2-620x442.jpg differ
diff --git a/LayoutTests/http/tests/resources/img-srcset/image2-840x600.jpg b/LayoutTests/http/tests/resources/img-srcset/image2-840x600.jpg
new file mode 100644 (file)
index 0000000..4e83d3a
Binary files /dev/null and b/LayoutTests/http/tests/resources/img-srcset/image2-840x600.jpg differ
diff --git a/LayoutTests/http/tests/resources/img-srcset/image3-250x178.jpg b/LayoutTests/http/tests/resources/img-srcset/image3-250x178.jpg
new file mode 100644 (file)
index 0000000..c546b59
Binary files /dev/null and b/LayoutTests/http/tests/resources/img-srcset/image3-250x178.jpg differ
diff --git a/LayoutTests/http/tests/resources/img-srcset/image3-615x438.jpg b/LayoutTests/http/tests/resources/img-srcset/image3-615x438.jpg
new file mode 100644 (file)
index 0000000..ebbfaa5
Binary files /dev/null and b/LayoutTests/http/tests/resources/img-srcset/image3-615x438.jpg differ
diff --git a/LayoutTests/http/tests/resources/img-srcset/image3-620x440.jpg b/LayoutTests/http/tests/resources/img-srcset/image3-620x440.jpg
new file mode 100644 (file)
index 0000000..0bc5212
Binary files /dev/null and b/LayoutTests/http/tests/resources/img-srcset/image3-620x440.jpg differ
diff --git a/LayoutTests/http/tests/resources/img-srcset/image3-700x498.jpg b/LayoutTests/http/tests/resources/img-srcset/image3-700x498.jpg
new file mode 100644 (file)
index 0000000..ca14cb4
Binary files /dev/null and b/LayoutTests/http/tests/resources/img-srcset/image3-700x498.jpg differ
diff --git a/LayoutTests/http/tests/resources/img-srcset/image3-840x598.jpg b/LayoutTests/http/tests/resources/img-srcset/image3-840x598.jpg
new file mode 100644 (file)
index 0000000..3439f6c
Binary files /dev/null and b/LayoutTests/http/tests/resources/img-srcset/image3-840x598.jpg differ
diff --git a/LayoutTests/http/tests/resources/img-srcset/image3.jpg b/LayoutTests/http/tests/resources/img-srcset/image3.jpg
new file mode 100644 (file)
index 0000000..3de4555
Binary files /dev/null and b/LayoutTests/http/tests/resources/img-srcset/image3.jpg differ
diff --git a/LayoutTests/http/tests/resources/img-srcset/image4-1024x612.jpg b/LayoutTests/http/tests/resources/img-srcset/image4-1024x612.jpg
new file mode 100644 (file)
index 0000000..6cc9a60
Binary files /dev/null and b/LayoutTests/http/tests/resources/img-srcset/image4-1024x612.jpg differ
diff --git a/LayoutTests/http/tests/resources/img-srcset/image4-300x179.jpg b/LayoutTests/http/tests/resources/img-srcset/image4-300x179.jpg
new file mode 100644 (file)
index 0000000..57f3292
Binary files /dev/null and b/LayoutTests/http/tests/resources/img-srcset/image4-300x179.jpg differ
diff --git a/LayoutTests/http/tests/resources/img-srcset/image4-620x370.jpg b/LayoutTests/http/tests/resources/img-srcset/image4-620x370.jpg
new file mode 100644 (file)
index 0000000..91e729d
Binary files /dev/null and b/LayoutTests/http/tests/resources/img-srcset/image4-620x370.jpg differ
diff --git a/LayoutTests/http/tests/resources/img-srcset/image4-768x459.jpg b/LayoutTests/http/tests/resources/img-srcset/image4-768x459.jpg
new file mode 100644 (file)
index 0000000..5bd2fd0
Binary files /dev/null and b/LayoutTests/http/tests/resources/img-srcset/image4-768x459.jpg differ
diff --git a/LayoutTests/http/tests/resources/img-srcset/image4-840x502.jpg b/LayoutTests/http/tests/resources/img-srcset/image4-840x502.jpg
new file mode 100644 (file)
index 0000000..b7fc0cc
Binary files /dev/null and b/LayoutTests/http/tests/resources/img-srcset/image4-840x502.jpg differ
diff --git a/LayoutTests/http/tests/resources/img-srcset/image4-940x560.jpg b/LayoutTests/http/tests/resources/img-srcset/image4-940x560.jpg
new file mode 100644 (file)
index 0000000..5ec53fb
Binary files /dev/null and b/LayoutTests/http/tests/resources/img-srcset/image4-940x560.jpg differ
index 4ed2aaf..bac8169 100644 (file)
@@ -1119,6 +1119,7 @@ webkit.org/b/85877 fast/forms/select-style.html [ Pass ]
 
 # EFL port needs Pasteboard implementation, needs baselines.
 webkit.org/b/84338 fast/forms/plaintext-mode-2.html [ Pass ]
+http/tests/images/hidpi-srcset-copy.html [ Skip ]
 
 # Controls are not zoomed.
 webkit.org/b/102367 fast/forms/zoomed-controls.html [ Pass ]
index 8c190bf..ddb6fd1 100644 (file)
@@ -2186,6 +2186,7 @@ webkit.org/b/122511 webkit.org/b/120401 fast/regions/selection/selecting-text-in
 
 # PasteBoard::plainText() does not support file names.
 webkit.org/b/99070 editing/pasteboard/drag-files-to-editable-element.html [ Failure ]
+http/tests/images/hidpi-srcset-copy.html [ Skip ]
 
 # Opera-submitted tests to W3C for <track>, a lot of failures still.
 webkit.org/b/103926 media/track/opera/idl/media-idl-tests.html [ Skip ]
index ae63968..7296662 100644 (file)
@@ -1230,6 +1230,8 @@ editing/pasteboard/emacs-cntl-y-001.html [ Failure ]
 # Assertion failure in replaySavedEvents
 webkit.org/b/21796 editing/pasteboard/drop-text-events.html [ Skip ]
 
+http/tests/images/hidpi-srcset-copy.html [ Skip ]
+
 ###### Selection
 editing/selection/ [ Pass Failure ]
 # This test is flaky due to capitalization; perhaps a capslock keypress or something?
index f6b111a..6bfd127 100644 (file)
@@ -1,3 +1,23 @@
+2016-05-16  Brent Fulgham  <bfulgham@apple.com>
+
+        REGRESSION (r192098): Content missing after copy and paste to Notes App on retina displays
+        https://bugs.webkit.org/show_bug.cgi?id=157630
+        <rdar://problem/25277577>
+
+        Reviewed by Simon Fraser.
+
+        Tested by http/tests/images/hidpi-srcset-copy.html
+
+        The code to create a WebArchive (or other representation) of a webpage was using the 'src' attribute of
+        the image element, which might be changed to reflect the optimal image dimensions for a specific
+        display. Instead, we should use the 'imageSourceURL' method of the Element class so we get the correct
+        'original' image URL in our cached resources.
+
+        * editing/cocoa/HTMLConverter.mm:
+        (HTMLConverter::_processElement): Use 'imageSourceURL', rather than getting the raw 'src' attribute.
+        * html/HTMLImageElement.cpp:
+        (WebCore::HTMLImageElement::addSubresourceAttributeURLs): Ditto.
+
 2016-05-16  Brady Eidson  <beidson@apple.com>
 
         Random CachedFont.cpp cleanup.
index 55679a7..d7f7e98 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2011, 2012 Apple Inc. All rights reserved.
+ * Copyright (C) 2011-2016 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -1901,7 +1901,7 @@ BOOL HTMLConverter::_processElement(Element& element, NSInteger depth)
         retval = NO;
 #endif
     } else if (element.hasTagName(imgTag)) {
-        NSString *urlString = element.getAttribute(srcAttr);
+        NSString *urlString = element.imageSourceURL();
         if (urlString && [urlString length] > 0) {
             NSURL *url = element.document().completeURL(stripLeadingAndTrailingHTMLSpaces(urlString));
             if (!url)
index 01693f0..9136094 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
  *           (C) 1999 Antti Koivisto (koivisto@kde.org)
- * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2010 Apple Inc. All rights reserved.
+ * Copyright (C) 2004-2016 Apple Inc. All rights reserved.
  * Copyright (C) 2010 Google Inc. All rights reserved.
  *
  * This library is free software; you can redistribute it and/or
@@ -542,7 +542,7 @@ void HTMLImageElement::addSubresourceAttributeURLs(ListHashSet<URL>& urls) const
 {
     HTMLElement::addSubresourceAttributeURLs(urls);
 
-    addSubresourceURL(urls, src());
+    addSubresourceURL(urls, document().completeURL(imageSourceURL()));
     // FIXME: What about when the usemap attribute begins with "#"?
     addSubresourceURL(urls, document().completeURL(fastGetAttribute(usemapAttr)));
 }
index 408beab..82719d9 100644 (file)
@@ -1,3 +1,36 @@
+2016-05-16  Brent Fulgham  <bfulgham@apple.com>
+
+        REGRESSION (r192098): Content missing after copy and paste to Notes App on retina displays
+        https://bugs.webkit.org/show_bug.cgi?id=157630
+        <rdar://problem/25277577>
+
+        Reviewed by Simon Fraser.
+
+        Update test infrastructure to support checking the number of images in the pasteboard.
+
+        * DumpRenderTree/TestRunner.cpp:
+        (imageCountInGeneralPasteboardCallback): Added.
+        (TestRunner::staticFunctions):
+        * DumpRenderTree/TestRunner.h:
+        * DumpRenderTree/mac/TestRunnerMac.mm:
+        (TestRunner::imageCountInGeneralPasteboard): Added.
+        * DumpRenderTree/win/TestRunnerWin.cpp:
+        (TestRunner::imageCountInGeneralPasteboard): Added stub method.
+        * WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl:
+        * WebKitTestRunner/InjectedBundle/InjectedBundle.cpp:
+        (WTR::InjectedBundle::imageCountInGeneralPasteboard): Added.
+        * WebKitTestRunner/InjectedBundle/InjectedBundle.h:
+        * WebKitTestRunner/InjectedBundle/TestRunner.cpp:
+        (WTR::TestRunner::imageCountInGeneralPasteboard): Added.
+        * WebKitTestRunner/InjectedBundle/TestRunner.h:
+        * WebKitTestRunner/TestController.cpp:
+        (WTR::TestController::imageCountInGeneralPasteboard): Added stub implementation.
+        * WebKitTestRunner/TestController.h:
+        * WebKitTestRunner/TestInvocation.cpp:
+        (WTR::TestInvocation::didReceiveSynchronousMessageFromInjectedBundle): Handle copy message.
+        * WebKitTestRunner/cocoa/TestControllerCocoa.mm:
+        (WTR::TestController::imageCountInGeneralPasteboard): Added.
+
 2016-05-13  Dewei Zhu  <dewei_zhu@apple.com>
 
         Fix JSBench which causes math domain error in run-benchmark script.
index 07a5c75..54d233e 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2007, 2008, 2009, 2011, 2012 Apple Inc. All rights reserved.
+ * Copyright (C) 2007-2016 Apple Inc. All rights reserved.
  * Copyright (C) 2010 Joone Hur <joone@kldp.org>
  *
  * Redistribution and use in source and binary forms, with or without
@@ -1747,6 +1747,14 @@ static JSValueRef preciseTimeCallback(JSContextRef context, JSObjectRef, JSObjec
     return JSValueMakeNumber(context, WTF::currentTime());
 }
 
+static JSValueRef imageCountInGeneralPasteboardCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
+{
+    // Has mac & windows implementation
+    TestRunner* controller = static_cast<TestRunner*>(JSObjectGetPrivate(thisObject));
+    
+    return JSValueMakeNumber(context, controller->imageCountInGeneralPasteboard());
+}
+
 // Static Values
 
 static JSValueRef getTimeoutCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception)
@@ -2175,6 +2183,7 @@ JSStaticFunction* TestRunner::staticFunctions()
         { "numberOfDFGCompiles", numberOfDFGCompiles, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "neverInlineFunction", neverInlineFunction, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "accummulateLogsForChannel", accummulateLogsForChannel, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
+        { "imageCountInGeneralPasteboard", imageCountInGeneralPasteboardCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { 0, 0, 0 }
     };
 
index f1b7bea..d1073c9 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2007, 2008, 2009, 2012 Apple Inc. All rights reserved.
+ * Copyright (C) 2007-2016 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -359,6 +359,8 @@ public:
     void setCustomTimeout(int duration) { m_timeout = duration; }
     double timeout() { return m_timeout; }
 
+    unsigned imageCountInGeneralPasteboard() const;
+    
 private:
     TestRunner(const std::string& testURL, const std::string& expectedPixelHash);
 
index 10b5284..41ace8b 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2007, 2008, 2009, 2012 Apple Inc. All rights reserved.
+ * Copyright (C) 2007-2016 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -1224,3 +1224,33 @@ void TestRunner::simulateLegacyWebNotificationClick(JSStringRef jsTitle)
 {
 }
 
+static NSString * const WebArchivePboardType = @"Apple Web Archive pasteboard type";
+static NSString * const WebSubresourcesKey = @"WebSubresources";
+static NSString * const WebSubframeArchivesKey = @"WebResourceMIMEType like 'image*'";
+
+unsigned TestRunner::imageCountInGeneralPasteboard() const
+{
+#if PLATFORM(MAC)
+    NSData *data = [[NSPasteboard generalPasteboard] dataForType:WebArchivePboardType];
+#elif PLATFORM(IOS)
+    NSData *data = [[UIPasteboard generalPasteboard] valueForPasteboardType:WebArchivePboardType];
+#endif
+    if (!data)
+        return 0;
+    
+    NSError *error = nil;
+    id webArchive = [NSPropertyListSerialization propertyListWithData:data options:NSPropertyListImmutable format:NULL error:&error];
+    if (error) {
+        NSLog(@"Encountered error while serializing Web Archive pasteboard data: %@", error);
+        return 0;
+    }
+    
+    NSArray *subItems = [NSArray arrayWithArray:[webArchive objectForKey:WebSubresourcesKey]];
+    NSPredicate *predicate = [NSPredicate predicateWithFormat:WebSubframeArchivesKey];
+    NSArray *imagesArray = [subItems filteredArrayUsingPredicate:predicate];
+    
+    if (!imagesArray)
+        return 0;
+    
+    return imagesArray.count;
+}
index 4e6c636..b66b4bf 100644 (file)
@@ -1333,3 +1333,10 @@ void TestRunner::simulateLegacyWebNotificationClick(JSStringRef title)
 {
     // FIXME: Implement.
 }
+
+unsigned TestRunner::imageCountInGeneralPasteboard() const
+{
+    printf("ERROR: TestRunner::imageCountInGeneralPasteboard() not implemented\n");
+    return 0;
+}
+
index 3fe186f..ecdb586 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2010, 2011, 2012 Apple Inc. All rights reserved.
+ * Copyright (C) 2010-2016 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -219,6 +219,8 @@ interface TestRunner {
     void installDidEndSwipeCallback(object callback);
     void installDidRemoveSwipeSnapshotCallback(object callback);
 
+    unsigned long imageCountInGeneralPasteboard();
+
     // UI Process Testing
     void runUIScript(DOMString script, object callback);
 
index 831903f..a03326e 100644 (file)
@@ -552,6 +552,16 @@ bool InjectedBundle::isGeolocationProviderActive() const
     return WKBooleanGetValue(isActive.get());
 }
 
+unsigned InjectedBundle::imageCountInGeneralPasteboard() const
+{
+    WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("ImageCountInGeneralPasteboard"));
+    WKTypeRef resultToPass = 0;
+    WKBundlePagePostSynchronousMessageForTesting(page()->page(), messageName.get(), 0, &resultToPass);
+    WKRetainPtr<WKUInt64Ref> imageCount(AdoptWK, static_cast<WKUInt64Ref>(resultToPass));
+    
+    return static_cast<unsigned>(WKUInt64GetValue(imageCount.get()));
+}
+
 void InjectedBundle::setUserMediaPermission(bool enabled)
 {
     auto messageName = adoptWK(WKStringCreateWithUTF8CString("SetUserMediaPermission"));
index 1558721..afd7767 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2010, 2011, 2012 Apple Inc. All rights reserved.
+ * Copyright (C) 2010-2016 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -121,6 +121,8 @@ public:
 
     bool isAllowedHost(WKStringRef);
 
+    unsigned imageCountInGeneralPasteboard() const;
+
 private:
     InjectedBundle();
     ~InjectedBundle();
index 0152417..fcf4990 100644 (file)
@@ -178,6 +178,11 @@ void TestRunner::notifyDone()
     m_waitToDump = false;
 }
 
+unsigned TestRunner::imageCountInGeneralPasteboard() const
+{
+    return InjectedBundle::singleton().imageCountInGeneralPasteboard();
+}
+
 void TestRunner::addUserScript(JSStringRef source, bool runAtStart, bool allFrames)
 {
     WKRetainPtr<WKStringRef> sourceWK = toWK(source);
index d08c933..39ec3fb 100644 (file)
@@ -322,6 +322,8 @@ public:
 
     void accummulateLogsForChannel(JSStringRef channel);
 
+    unsigned imageCountInGeneralPasteboard() const;
+
 private:
     TestRunner();
 
index 5d59bcf..b397a69 100644 (file)
@@ -2163,6 +2163,12 @@ void TestController::platformResetStateToConsistentValues()
 {
 
 }
+
+unsigned TestController::imageCountInGeneralPasteboard() const
+{
+    return 0;
+}
+
 #endif
 
 } // namespace WTR
index cbdfdca..fe5c635 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2010, 2015 Apple Inc. All rights reserved.
+ * Copyright (C) 2010, 2015-2016 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -111,6 +111,8 @@ public:
     // Page Visibility.
     void setHidden(bool);
 
+    unsigned imageCountInGeneralPasteboard() const;
+
     bool resetStateToConsistentValues(const TestOptions&);
     void resetPreferencesToConsistentValues(const TestOptions&);
 
index b593674..873a9d5 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2010, 2011, 2012 Apple Inc. All rights reserved.
+ * Copyright (C) 2010-2016 Apple Inc. All rights reserved.
  * Copyright (C) 2012 Intel Corporation. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -708,6 +708,12 @@ WKRetainPtr<WKTypeRef> TestInvocation::didReceiveSynchronousMessageFromInjectedB
         return nullptr;
     }
 
+    if (WKStringIsEqualToUTF8CString(messageName, "ImageCountInGeneralPasteboard")) {
+        unsigned count = TestController::singleton().imageCountInGeneralPasteboard();
+        WKRetainPtr<WKUInt64Ref> result(AdoptWK, WKUInt64Create(count));
+        return result;
+    }
+    
     ASSERT_NOT_REACHED();
     return nullptr;
 }
index 4817336..09a0717 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2015 Apple Inc. All rights reserved.
+ * Copyright (C) 2015-2016 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -142,4 +142,35 @@ void TestController::platformWillRunTest(const TestInvocation& testInvocation)
     setCrashReportApplicationSpecificInformationToURL(testInvocation.url());
 }
 
+static NSString * const WebArchivePboardType = @"Apple Web Archive pasteboard type";
+static NSString * const WebSubresourcesKey = @"WebSubresources";
+static NSString * const WebSubframeArchivesKey = @"WebResourceMIMEType like 'image*'";
+
+unsigned TestController::imageCountInGeneralPasteboard() const
+{
+#if PLATFORM(MAC)
+    NSData *data = [[NSPasteboard generalPasteboard] dataForType:WebArchivePboardType];
+#elif PLATFORM(IOS)
+    NSData *data = [[UIPasteboard generalPasteboard] valueForPasteboardType:WebArchivePboardType];
+#endif
+    if (!data)
+        return 0;
+    
+    NSError *error = nil;
+    id webArchive = [NSPropertyListSerialization propertyListWithData:data options:NSPropertyListImmutable format:NULL error:&error];
+    if (error) {
+        NSLog(@"Encountered error while serializing Web Archive pasteboard data: %@", error);
+        return 0;
+    }
+    
+    NSArray *subItems = [NSArray arrayWithArray:[webArchive objectForKey:WebSubresourcesKey]];
+    NSPredicate *predicate = [NSPredicate predicateWithFormat:WebSubframeArchivesKey];
+    NSArray *imagesArray = [subItems filteredArrayUsingPredicate:predicate];
+    
+    if (!imagesArray)
+        return 0;
+    
+    return imagesArray.count;
+}
+
 } // namespace WTR