Title: [207593] branches/safari-602-branch

Diff

Modified: branches/safari-602-branch/Source/WebCore/ChangeLog (207592 => 207593)


--- branches/safari-602-branch/Source/WebCore/ChangeLog	2016-10-20 09:58:58 UTC (rev 207592)
+++ branches/safari-602-branch/Source/WebCore/ChangeLog	2016-10-20 09:59:02 UTC (rev 207593)
@@ -1,3 +1,23 @@
+2016-10-20  Matthew Hanson  <matthew_han...@apple.com>
+
+        Merge r205212. rdar://problem/28476952
+
+    2016-08-30  Ricky Mondello  <rmonde...@apple.com>
+
+            YouTubePluginReplacementTest's URL transformation logic should have tests
+            https://bugs.webkit.org/show_bug.cgi?id=161406
+            <rdar://problem/28050847>
+
+            Reviewed by Eric Carlson.
+
+            Refactor most of YouTubePluginReplacement::youTubeURL into a static method that can be used by TestWebKitAPI.
+
+            * Modules/plugins/YouTubePluginReplacement.cpp:
+            (WebCore::YouTubePluginReplacement::youTubeURL): Now implemented in terms of youTubeURLFromAbsoluteURL.
+            (WebCore::YouTubePluginReplacement::youTubeURLFromAbsoluteURL): Absorbs most of youTubeURL.
+            * Modules/plugins/YouTubePluginReplacement.h: Declare a public method, for the benefit of testing.
+            * WebCore.xcodeproj/project.pbxproj: Make some heads private for TestWebKitAPI's benefit.
+
 2016-08-25  Brent Fulgham  <bfulg...@apple.com>
 
         Merge r205163. rdar://problem/28216249

Modified: branches/safari-602-branch/Source/WebCore/Modules/plugins/YouTubePluginReplacement.cpp (207592 => 207593)


--- branches/safari-602-branch/Source/WebCore/Modules/plugins/YouTubePluginReplacement.cpp	2016-10-20 09:58:58 UTC (rev 207592)
+++ branches/safari-602-branch/Source/WebCore/Modules/plugins/YouTubePluginReplacement.cpp	2016-10-20 09:59:02 UTC (rev 207593)
@@ -283,7 +283,11 @@
 String YouTubePluginReplacement::youTubeURL(const String& srcString)
 {
     URL srcURL = m_parentElement->document().completeURL(stripLeadingAndTrailingHTMLSpaces(srcString));
+    return youTubeURLFromAbsoluteURL(srcURL, srcString);
+}
 
+String YouTubePluginReplacement::youTubeURLFromAbsoluteURL(const URL& srcURL, const String& srcString)
+{
     bool isYouTubeShortenedURL = false;
     URL youTubeURL = processAndCreateYouTubeURL(srcURL, isYouTubeShortenedURL);
     if (srcURL.isEmpty() || youTubeURL.isEmpty())

Modified: branches/safari-602-branch/Source/WebCore/Modules/plugins/YouTubePluginReplacement.h (207592 => 207593)


--- branches/safari-602-branch/Source/WebCore/Modules/plugins/YouTubePluginReplacement.h	2016-10-20 09:58:58 UTC (rev 207592)
+++ branches/safari-602-branch/Source/WebCore/Modules/plugins/YouTubePluginReplacement.h	2016-10-20 09:59:02 UTC (rev 207593)
@@ -38,6 +38,8 @@
 
     typedef HashMap<String, String> KeyValueMap;
 
+    WEBCORE_EXPORT static String youTubeURLFromAbsoluteURL(const URL& srcURL, const String& srcString);
+
 private:
     YouTubePluginReplacement(HTMLPlugInElement&, const Vector<String>& paramNames, const Vector<String>& paramValues);
     static Ref<PluginReplacement> create(HTMLPlugInElement&, const Vector<String>& paramNames, const Vector<String>& paramValues);

Modified: branches/safari-602-branch/Source/WebCore/WebCore.xcodeproj/project.pbxproj (207592 => 207593)


--- branches/safari-602-branch/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2016-10-20 09:58:58 UTC (rev 207592)
+++ branches/safari-602-branch/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2016-10-20 09:59:02 UTC (rev 207593)
@@ -132,7 +132,7 @@
 		07277E5517D018CC0015534D /* JSMediaStreamTrackEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = 07277E4917D018CC0015534D /* JSMediaStreamTrackEvent.h */; };
 		07297FA71C1881C5003F0735 /* UserMediaPermissionCheck.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 07297FA51C1881C5003F0735 /* UserMediaPermissionCheck.cpp */; };
 		07297FA81C1881C5003F0735 /* UserMediaPermissionCheck.h in Headers */ = {isa = PBXBuildFile; fileRef = 07297FA61C1881C5003F0735 /* UserMediaPermissionCheck.h */; settings = {ATTRIBUTES = (Private, ); }; };
-		072AE1E5183C0741000A5988 /* PluginReplacement.h in Headers */ = {isa = PBXBuildFile; fileRef = 072AE1DF183C0741000A5988 /* PluginReplacement.h */; };
+		072AE1E5183C0741000A5988 /* PluginReplacement.h in Headers */ = {isa = PBXBuildFile; fileRef = 072AE1DF183C0741000A5988 /* PluginReplacement.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		072AE1E6183C0741000A5988 /* QuickTimePluginReplacement.mm in Sources */ = {isa = PBXBuildFile; fileRef = 072AE1E0183C0741000A5988 /* QuickTimePluginReplacement.mm */; };
 		072AE1E8183C0741000A5988 /* QuickTimePluginReplacement.h in Headers */ = {isa = PBXBuildFile; fileRef = 072AE1E2183C0741000A5988 /* QuickTimePluginReplacement.h */; };
 		072C8B11131C518600A4FCE9 /* MediaPlayerPrivateAVFoundation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 076F0D0912B8192700C26AA4 /* MediaPlayerPrivateAVFoundation.cpp */; };
@@ -2743,7 +2743,7 @@
 		7A54858014E02D51006AE05A /* InspectorHistory.h in Headers */ = {isa = PBXBuildFile; fileRef = 7A54857E14E02D51006AE05A /* InspectorHistory.h */; };
 		7A54881714E432A1006AE05A /* DOMPatchSupport.h in Headers */ = {isa = PBXBuildFile; fileRef = 7A54881514E432A1006AE05A /* DOMPatchSupport.h */; };
 		7A54881814E432A1006AE05A /* DOMPatchSupport.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7A54881614E432A1006AE05A /* DOMPatchSupport.cpp */; };
-		7A5515F5191830A3009687D2 /* YouTubePluginReplacement.h in Headers */ = {isa = PBXBuildFile; fileRef = 7A5515F3191830A3009687D2 /* YouTubePluginReplacement.h */; };
+		7A5515F5191830A3009687D2 /* YouTubePluginReplacement.h in Headers */ = {isa = PBXBuildFile; fileRef = 7A5515F3191830A3009687D2 /* YouTubePluginReplacement.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		7A5515F6191830A3009687D2 /* YouTubePluginReplacement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7A5515F4191830A3009687D2 /* YouTubePluginReplacement.cpp */; };
 		7A674BDB0F9EBF4E006CF099 /* PageGroupLoadDeferrer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7A674BD90F9EBF4E006CF099 /* PageGroupLoadDeferrer.cpp */; };
 		7A674BDC0F9EBF4E006CF099 /* PageGroupLoadDeferrer.h in Headers */ = {isa = PBXBuildFile; fileRef = 7A674BDA0F9EBF4E006CF099 /* PageGroupLoadDeferrer.h */; };

Modified: branches/safari-602-branch/Tools/ChangeLog (207592 => 207593)


--- branches/safari-602-branch/Tools/ChangeLog	2016-10-20 09:58:58 UTC (rev 207592)
+++ branches/safari-602-branch/Tools/ChangeLog	2016-10-20 09:59:02 UTC (rev 207593)
@@ -1,3 +1,22 @@
+2016-10-20  Matthew Hanson  <matthew_han...@apple.com>
+
+        Merge r205212. rdar://problem/28476952
+
+    2016-08-30  Ricky Mondello  <rmonde...@apple.com>
+
+            YouTubePluginReplacementTest's URL transformation logic should have tests
+            https://bugs.webkit.org/show_bug.cgi?id=161406
+            <rdar://problem/28050847>
+
+            Reviewed by Eric Carlson.
+
+            Add some very basic tests. Future patches should expand on these to find and fix bugs.
+
+            * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: Add YouTubePluginReplacement.cpp.
+            * TestWebKitAPI/Tests/WebCore/YouTubePluginReplacement.cpp: Added.
+            (TestWebKitAPI::test): Added.
+            (TestWebKitAPI::TEST_F): Added.
+
 2016-10-12  Matthew Hanson  <matthew_han...@apple.com>
 
         Merge r205197. rdar://problem/28481424

Modified: branches/safari-602-branch/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (207592 => 207593)


--- branches/safari-602-branch/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj	2016-10-20 09:58:58 UTC (rev 207592)
+++ branches/safari-602-branch/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj	2016-10-20 09:59:02 UTC (rev 207593)
@@ -395,6 +395,7 @@
 		9B0786A51C5885C300D159E3 /* InjectedBundleMakeAllShadowRootOpen_Bundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9B0786A41C5885C300D159E3 /* InjectedBundleMakeAllShadowRootOpen_Bundle.cpp */; };
 		9B26FCCA159D16DE00CC3765 /* HTMLFormCollectionNamedItem.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 9B26FCB4159D15E700CC3765 /* HTMLFormCollectionNamedItem.html */; };
 		9B4F8FA7159D52DD002D9F94 /* HTMLCollectionNamedItem.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 9B4F8FA6159D52CA002D9F94 /* HTMLCollectionNamedItem.html */; };
+		9C64DC321D76198A004B598E /* YouTubePluginReplacement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9C64DC311D76198A004B598E /* YouTubePluginReplacement.cpp */; };
 		A1146A8D1D2D7115000FE710 /* ContentFiltering.mm in Sources */ = {isa = PBXBuildFile; fileRef = A1146A8A1D2D704F000FE710 /* ContentFiltering.mm */; };
 		A13EBBAA1B87428D00097110 /* WebProcessPlugIn.mm in Sources */ = {isa = PBXBuildFile; fileRef = A13EBBA91B87428D00097110 /* WebProcessPlugIn.mm */; };
 		A13EBBAB1B87434600097110 /* PlatformUtilitiesCocoa.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0F139E721A423A2B00F590F5 /* PlatformUtilitiesCocoa.mm */; };
@@ -987,6 +988,7 @@
 		9B4F8FA3159D52B1002D9F94 /* HTMLCollectionNamedItem.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = HTMLCollectionNamedItem.mm; sourceTree = "<group>"; };
 		9B4F8FA6159D52CA002D9F94 /* HTMLCollectionNamedItem.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = HTMLCollectionNamedItem.html; sourceTree = "<group>"; };
 		9B79164F1BD89D0D00D50B8F /* FirstResponderScrollingPosition.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = FirstResponderScrollingPosition.mm; sourceTree = "<group>"; };
+		9C64DC311D76198A004B598E /* YouTubePluginReplacement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = YouTubePluginReplacement.cpp; sourceTree = "<group>"; };
 		A1146A8A1D2D704F000FE710 /* ContentFiltering.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ContentFiltering.mm; sourceTree = "<group>"; };
 		A13EBB491B87339E00097110 /* TestWebKitAPI.wkbundle */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = TestWebKitAPI.wkbundle; sourceTree = BUILT_PRODUCTS_DIR; };
 		A13EBB521B87346600097110 /* WebProcessPlugIn.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = WebProcessPlugIn.xcconfig; sourceTree = "<group>"; };
@@ -1380,6 +1382,7 @@
 				7AD3FE8D1D75FB8D00B169A4 /* TransformationMatrix.cpp */,
 				440A1D3814A0103A008A66F2 /* URL.cpp */,
 				7C3965051CDD74F90094DBB8 /* Color.cpp */,
+				9C64DC311D76198A004B598E /* YouTubePluginReplacement.cpp */,
 			);
 			path = WebCore;
 			sourceTree = "<group>";
@@ -2423,6 +2426,7 @@
 				7CCE7F1F1A411AE600447C4C /* WKPageGetScaleFactorNotZero.cpp in Sources */,
 				7CCE7F201A411AE600447C4C /* WKPageIsPlayingAudio.cpp in Sources */,
 				7CCE7F211A411AE600447C4C /* WKPreferences.cpp in Sources */,
+				9C64DC321D76198A004B598E /* YouTubePluginReplacement.cpp in Sources */,
 				7CCE7F221A411AE600447C4C /* WKString.cpp in Sources */,
 				7CCE7F1E1A411AE600447C4C /* WKStringJSString.cpp in Sources */,
 			);

Added: branches/safari-602-branch/Tools/TestWebKitAPI/Tests/WebCore/YouTubePluginReplacement.cpp (0 => 207593)


--- branches/safari-602-branch/Tools/TestWebKitAPI/Tests/WebCore/YouTubePluginReplacement.cpp	                        (rev 0)
+++ branches/safari-602-branch/Tools/TestWebKitAPI/Tests/WebCore/YouTubePluginReplacement.cpp	2016-10-20 09:59:02 UTC (rev 207593)
@@ -0,0 +1,73 @@
+/*
+ * Copyright (C) 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
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include <WebCore/URL.h>
+#include <WebCore/YouTubePluginReplacement.h>
+#include <wtf/MainThread.h>
+
+using namespace WebCore;
+
+namespace TestWebKitAPI {
+
+class YouTubePluginReplacementTest : public testing::Test {
+public:
+    void SetUp() final {
+        WTF::initializeMainThread();
+    }
+};
+
+static bool test(const String& inputURLString, const String& expectedURLString)
+{
+    URL inputURL(URL(), inputURLString);
+    String actualURLString = YouTubePluginReplacement::youTubeURLFromAbsoluteURL(inputURL, inputURLString);
+    return actualURLString.utf8() == expectedURLString.utf8();
+}
+
+TEST_F(YouTubePluginReplacementTest, YouTubeURLFromAbsoluteURL)
+{
+    // YouTube non-video URL, not expected to be transformed.
+    EXPECT_TRUE(test("https://www.youtube.com", "https://www.youtube.com"));
+
+    // Basic YouTube video links, expected to be transformed.
+    EXPECT_TRUE(test("https://www.youtube.com/v/dQw4w9WgXcQ", "https://www.youtube.com/embed/dQw4w9WgXcQ?showinfo=0"));
+    EXPECT_TRUE(test("http://www.youtube.com/v/dQw4w9WgXcQ", "http://www.youtube.com/embed/dQw4w9WgXcQ?showinfo=0"));
+    EXPECT_TRUE(test("https://youtube.com/v/dQw4w9WgXcQ", "https://youtube.com/embed/dQw4w9WgXcQ?showinfo=0"));
+    EXPECT_TRUE(test("http://youtube.com/v/dQw4w9WgXcQ", "http://youtube.com/embed/dQw4w9WgXcQ?showinfo=0"));
+
+    // With start time, preserved.
+    EXPECT_TRUE(test("http://www.youtube.com/v/dQw4w9WgXcQ?start=4", "http://www.youtube.com/embed/dQw4w9WgXcQ?start=4&showinfo=0"));
+    EXPECT_TRUE(test("http://www.youtube.com/v/dQw4w9WgXcQ?start=4&fs=1", "http://www.youtube.com/embed/dQw4w9WgXcQ?start=4&fs=1&showinfo=0"));
+
+    // Non-Flash URL is untouched.
+    EXPECT_TRUE(test("https://www.youtube.com/embed/dQw4w9WgXcQ", "https://www.youtube.com/embed/dQw4w9WgXcQ"));
+    // Even with an extra parameter.
+    EXPECT_TRUE(test("http://www.youtube.com/embed/dQw4w9WgXcQ?enablejsapi=1", "http://www.youtube.com/embed/dQw4w9WgXcQ?enablejsapi=1"));
+
+    // Non-YouTube domain whose path looks like a Flash video shouldn't be transformed.
+    EXPECT_TRUE(test("https://www.notyoutube.com/v/dQw4w9WgXcQ", "https://www.notyoutube.com/v/dQw4w9WgXcQ"));
+}
+
+} // namespace TestWebKitAPI
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to