+#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 110000
+
+TEST(UIPasteboardTests, DoNotPastePlainTextAsURL)
+{
+ auto webView = setUpWebViewForPasteboardTests();
+
+ NSString *testString = @"[helloworld]";
+ [UIPasteboard generalPasteboard].string = testString;
+
+ [webView stringByEvaluatingJavaScript:@"selectPlainText()"];
+ [webView stringByEvaluatingJavaScript:@"document.execCommand('paste')"];
+ EXPECT_WK_STREQ(testString, [webView stringByEvaluatingJavaScript:@"plain.value"]);
+
+ [webView stringByEvaluatingJavaScript:@"selectRichText()"];
+ [webView stringByEvaluatingJavaScript:@"document.execCommand('paste')"];
+ EXPECT_WK_STREQ(testString, [webView stringByEvaluatingJavaScript:@"rich.textContent"]);
+ EXPECT_FALSE([webView stringByEvaluatingJavaScript:@"!!rich.querySelector('a')"].boolValue);
+}
+
+TEST(UIPasteboardTests, PastePlainTextAsURL)
+{
+ auto webView = setUpWebViewForPasteboardTests();
+
+ NSString *testString = @"https://www.apple.com/iphone";
+ [UIPasteboard generalPasteboard].string = testString;
+
+ [webView stringByEvaluatingJavaScript:@"selectPlainText()"];
+ [webView stringByEvaluatingJavaScript:@"document.execCommand('paste')"];
+ EXPECT_WK_STREQ(testString, [webView stringByEvaluatingJavaScript:@"plain.value"]);
+
+ [webView stringByEvaluatingJavaScript:@"selectRichText()"];
+ [webView stringByEvaluatingJavaScript:@"document.execCommand('paste')"];
+ EXPECT_WK_STREQ(testString, [webView stringByEvaluatingJavaScript:@"rich.textContent"]);
+ EXPECT_TRUE([webView stringByEvaluatingJavaScript:@"!!rich.querySelector('a')"].boolValue);
+}
+
+TEST(UIPasteboardTests, PasteURLWithPlainTextAsURL)
+{
+ auto webView = setUpWebViewForPasteboardTests();
+
+ NSString *testString = @"thisisdefinitelyaurl";
+ [UIPasteboard generalPasteboard].URL = [NSURL URLWithString:testString];
+
+ [webView stringByEvaluatingJavaScript:@"selectPlainText()"];
+ [webView stringByEvaluatingJavaScript:@"document.execCommand('paste')"];
+ EXPECT_WK_STREQ(testString, [webView stringByEvaluatingJavaScript:@"plain.value"]);
+
+ [webView stringByEvaluatingJavaScript:@"selectRichText()"];
+ [webView stringByEvaluatingJavaScript:@"document.execCommand('paste')"];
+ EXPECT_WK_STREQ(testString, [webView stringByEvaluatingJavaScript:@"rich.textContent"]);
+ EXPECT_TRUE([webView stringByEvaluatingJavaScript:@"!!rich.querySelector('a')"].boolValue);
+}
+
+#endif // __IPHONE_OS_VERSION_MIN_REQUIRED >= 110000
+