diff --git a/build/ShouldSkipPRBuild.ps1 b/build/ShouldSkipPRBuild.ps1 index 8a469b9115..43cb5a9e13 100644 --- a/build/ShouldSkipPRBuild.ps1 +++ b/build/ShouldSkipPRBuild.ps1 @@ -11,8 +11,16 @@ function AllChangedFilesAreSkippable foreach($file in $files) { Write-Host "Checking '$file'" - $ext = [System.IO.Path]::GetExtension($file) - $fileIsSkippable = $ext -in $skipExts + try + { + $ext = [System.IO.Path]::GetExtension($file) + $fileIsSkippable = $ext -in $skipExts + } + catch + { + $fileIsSkippable = $false + } + Write-Host "File '$file' is skippable: '$fileIsSkippable'" if(!$fileIsSkippable) diff --git a/dev/WebView2/InteractionTests/WebView2Tests.cs b/dev/WebView2/InteractionTests/WebView2Tests.cs index 7c2f31fcb6..3a425362f1 100644 --- a/dev/WebView2/InteractionTests/WebView2Tests.cs +++ b/dev/WebView2/InteractionTests/WebView2Tests.cs @@ -609,7 +609,7 @@ public void MouseWheelScrollTest() using (var setup = new WebView2TestSetupHelper(new[] { "WebView2 Tests", "navigateToBasicWebView2" })) { ChooseTest("MouseWheelScrollTest"); - + var webview = FindElement.ById("MyWebView2"); // Mouse wheel delta amount required per initial velocity unit const int mouseWheelDeltaForVelocityUnit = -4000; // scroll downwards @@ -749,7 +749,7 @@ public void Focus_BasicTabTest() } // See comment on Focus_BasicTabTest() for details on test mechanism. - [TestMethod] + [TestMethod] [TestProperty("TestSuite", "A")] public void Focus_ReverseTabTest() { @@ -807,7 +807,7 @@ public void Focus_ReverseTabTest() } // See comment on Focus_BasicTabTest() for details on test mechanism. - [TestMethod] + [TestMethod] [TestProperty("TestSuite", "A")] public void Focus_BackAndForthTabTest() { @@ -956,7 +956,7 @@ public void ExecuteScriptTest() } } - [TestMethod] + [TestMethod] [TestProperty("TestSuite", "A")] public void MultipleWebviews_FocusTest() { @@ -1021,7 +1021,7 @@ public void MultipleWebviews_FocusTest() } } - [TestMethod] + [TestMethod] [TestProperty("TestSuite", "B")] public void MultipleWebviews_BasicRenderingTest() { @@ -1066,6 +1066,7 @@ public void MultipleWebviews_LanguageTest() // the Xaml app to provide an isolated 'copy from webview' test. [TestMethod] [TestProperty("TestSuite", "B")] + [TestProperty("Ignore", "True")] // Task 37000273 public void CopyPasteTest() { if (!PlatformConfiguration.IsOsVersionGreaterThanOrEqual(OSVersion.Redstone5)) @@ -1078,10 +1079,10 @@ public void CopyPasteTest() { var result = new Edit(FindElement.ById("TestResult")); ChooseTest("CopyPasteTest"); - + var CopyPasteTextBox1 = new Edit(FindElement.ById("CopyPasteTextBox1")); var CopyPasteTextBox2 = new Edit(FindElement.ById("CopyPasteTextBox2")); - + // Copy text to SimpleInputPage's text box page. CopyPasteTextBox1.SetFocus(); DoSelectAllByKeyboard(); @@ -1154,44 +1155,54 @@ public void BasicKeyboardTest() // Result should be "Hello 123 World" via: // Write Hello Wor after navigating to textbox in webview. Button x1 = new Button(FindElement.ById("TabStopButton1")); // Xaml TabStop 1 + Log.Comment("Set focus on x1 and verify it has keyboard focus..."); x1.SetFocus(); Wait.ForIdle(); Verify.IsTrue(x1.HasKeyboardFocus); + + Log.Comment("Tab to w1..."); KeyboardHelper.PressKey(Key.Tab); WaitForFocus("w1"); + + Log.Comment("Inject 'Hello Wor'..."); TextInput.SendText("Hello Wor"); - // Inject Left arrow three times. + + Log.Comment("Inject left arrow three times..."); KeyboardHelper.PressKey(Key.Left); KeyboardHelper.PressKey(Key.Left); KeyboardHelper.PressKey(Key.Left); - // Inject "123 " + + Log.Comment("Inject '123 '..."); TextInput.SendText("123 "); - // Inject right arrow three times + + Log.Comment("Inject right arrow three times..."); KeyboardHelper.PressKey(Key.Right); KeyboardHelper.PressKey(Key.Right); KeyboardHelper.PressKey(Key.Right); - // Inject "ld" + + Log.Comment("Inject 'ld'..."); TextInput.SendText("ld"); - // Test simultaneous keyboard inputs + + Log.Comment("Test simultaneous keyboard inputs by injecting shift+left twice..."); KeyboardHelper.PressKey(Key.Left, ModifierKey.Shift); KeyboardHelper.PressKey(Key.Left, ModifierKey.Shift); TextInput.SendText("m"); + // Copy out to PasteBox1 for verification. + Log.Comment("Select All by keyboard..."); DoSelectAllByKeyboard(); + Log.Comment("Copy selected..."); CopySelected(); + Log.Comment("Move focus to CopyPasteTextBox2..."); CopyPasteTextBox2.SetFocus(); + Log.Comment("Paste clipboard..."); PasteClipboard(); - // Tab to button - x1.SetFocus(); - Wait.ForIdle(); - Verify.IsTrue(x1.HasKeyboardFocus); - KeyboardHelper.PressKey(Key.Tab); - KeyboardHelper.PressKey(Key.Tab); - WaitForFocus("b1"); - // Inject "ENTER" - KeyboardHelper.PressKey(Key.Enter); - Wait.ForIdle(); + string expectedText = "Hello 123 Worm"; + string textResult = CopyPasteTextBox2.GetText(); + Verify.IsTrue(textResult == expectedText, + string.Format("Test {0}: Expected text {1} did not match with sampled text {2}.", + "BasicKeyboardTest", expectedText, textResult)); CompleteTestAndWaitForResult("BasicKeyboardTest"); } @@ -1742,7 +1753,7 @@ public void ParentVisibilityTurnedOnTest() CompleteTestAndWaitForWebMessageResult("ParentVisibilityTurnedOnTest"); } } - + [TestMethod] [TestProperty("Ignore", "True")] // TODO_WebView2: Enable when we can change DPI for a test [TestProperty("TestSuite", "C")] @@ -1762,7 +1773,7 @@ public void SpecificTouchTest() var status2 = new Edit(FindElement.ById("Status2")); // Click the button in the middle of the webview. It should be square 35. - InputHelper.MoveMouse(webview, 0 , 0); + InputHelper.MoveMouse(webview, 0, 0); Log.Comment("Do left click..."); PointerInput.Press(PointerButtons.Primary); PointerInput.Release(PointerButtons.Primary); @@ -1995,21 +2006,21 @@ public void PointerReleaseWithoutPressTest() using (var setup = new WebView2TestSetupHelper(new[] { "WebView2 Tests", "navigateToBasicWebView2" })) { ChooseTest("PointerReleaseWithoutPressTest"); - + var webview = FindElement.ById("MyWebView2"); Rectangle bounds = webview.BoundingRectangle; - + // First, click outside the webview. Then with the mouse button still pressed, // drag into the webview and release the mouse button. This should neither // send a message to CoreWebView2, nor should it crash the app. - + var point = new Point(bounds.X + bounds.Width + 20, bounds.Y + 20); PointerInput.Move(point); PointerInput.Press(PointerButtons.Primary); point = new Point(bounds.X + bounds.Width - 20, bounds.Y + 20); PointerInput.Move(point); PointerInput.Release(PointerButtons.Primary); - + CompleteTestAndWaitForResult("PointerReleaseWithoutPressTest"); } } @@ -2137,6 +2148,37 @@ public void UserAgentTest() } } + [TestMethod] + [TestProperty("TestSuite", "D")] + public void NonAsciiUriTest() + { + if (!PlatformConfiguration.IsOsVersionGreaterThanOrEqual(OSVersion.Redstone5)) + { + Log.Warning("CoreWebView2 doesn't work RS2-RS4 yet"); + return; + } + + using (var setup = new WebView2TestSetupHelper(new[] { "WebView2 Tests", "navigateToBasicWebView2" })) + { + // Navigate to a uri with a non-ascii characters + ChooseTest("NonAsciiUriTest"); + CompleteTestAndWaitForResult("NonAsciiUriTest"); + + // At the end of the test, we should only have gotten one NavigationStarting message. + // All messages would have been printed to the MessageLog, so count the NavigationStarting + // messages there. + int count = 0; + var logBox = new Edit(FindElement.ById("MessageLog")); + var messageWords = logBox.GetText().Split(' '); + foreach (string word in messageWords) + { + if (word.Equals("NavigationStarting")) count++; + } + + Verify.AreEqual(count, 1); + } + } + private static void BeginSubTest(string testName, string testDescription) { Log.Comment(Environment.NewLine + testName + ": " + testDescription); diff --git a/dev/WebView2/TestUI/WebView2BasicPage.xaml b/dev/WebView2/TestUI/WebView2BasicPage.xaml index f8dd92f9fd..f84c72f3ae 100644 --- a/dev/WebView2/TestUI/WebView2BasicPage.xaml +++ b/dev/WebView2/TestUI/WebView2BasicPage.xaml @@ -59,6 +59,7 @@ NavigateToVideoTest NavigationErrorTest NavigationStartingTest + NonAsciiUriTest ParentVisibilityHiddenTest ParentVisibilityTurnedOnTest PointerReleaseWithoutPressTest diff --git a/dev/WebView2/TestUI/WebView2BasicPage.xaml.cs b/dev/WebView2/TestUI/WebView2BasicPage.xaml.cs index e6bf0c18e0..93c255e70d 100644 --- a/dev/WebView2/TestUI/WebView2BasicPage.xaml.cs +++ b/dev/WebView2/TestUI/WebView2BasicPage.xaml.cs @@ -196,6 +196,7 @@ enum TestList CloseThenDPIChangeTest, AddHostObjectToScriptTest, UserAgentTest, + NonAsciiUriTest, }; // Map of TestList entry to its webpage (index in TestPageNames[]) @@ -255,6 +256,7 @@ enum TestList { TestList.CloseThenDPIChangeTest, 0 }, { TestList.AddHostObjectToScriptTest, 0 }, { TestList.UserAgentTest, 0 }, + { TestList.NonAsciiUriTest, 7 }, }; readonly string[] TestPageNames = @@ -266,6 +268,7 @@ enum TestList "SimplePageWithText.html", "SimpleInputPage.html", "SimplePageWithManyButtons.html", + "SimplePageWithNonÅscií.html", }; readonly WebView2Common _helpers; @@ -660,6 +663,16 @@ private void TestNameComboBox_SelectionChanged(object sender, SelectionChangedEv WebView2Common.LoadWebPage(newWebView2, TestPageNames[TestInfoDictionary[test]]); } break; + case TestList.NonAsciiUriTest: + { + // Put the URI with non-ascii characters in a TextBox, so we can easily copy/paste for manual testing. + var box = FindName("CopyPasteTextBox2") as TextBox; + string fileLocation = WebView2Common.GetTestPageUri("SimplePageWithNonÅscií.html").ToString(); + string query = "?query="; + box.Text = fileLocation + query; + WebView2Common.LoadWebPage(MyWebView2, TestPageNames[TestInfoDictionary[test]]); + } + break; default: WebView2Common.LoadWebPage(MyWebView2, TestPageNames[TestInfoDictionary[test]]); break; @@ -692,6 +705,8 @@ async public void UpdatingAnaheimFocusToolTipOpenedMultipleWebview(object sender private void OnNavigationStarting(WebView2 sender, CoreWebView2NavigationStartingEventArgs args) { + // Be careful if changing this message. The "NavigationStarting" string is expected + // to be logged exactly once per NavigationStarting event by the NonAsciiUriTest. AppendMessage(string.Format("[{0}]: Got NavigationStarting ({1}).", sender.Name, args.Uri)); string expectedUri = "http://www.blockedbynavigationstarting.invalid/"; @@ -1247,21 +1262,6 @@ async public void CompleteCurrentTest(object sender, RoutedEventArgs args) } break; - case TestList.BasicKeyboardTest: - { - string expectedMessage = "Input button clicked."; - string receivedMessage = Status2.Text; - logger.Verify((expectedMessage == receivedMessage), - string.Format("Test {0}: Expected web message {1} did not match received web message {2}.", - selectedTest.ToString(), expectedMessage, receivedMessage)); - string expectedText = "Hello 123 Worm"; - string textResult = CopyPasteTextBox2.Text; - logger.Verify((textResult == expectedText), - string.Format("Test {0}: Expected text {1} did not match with sampled text {2}.", - selectedTest.ToString(), expectedText, textResult)); - } - break; - case TestList.MouseCaptureTest: { string textResult = CopyPasteTextBox2.Text; diff --git a/dev/WebView2/WebView2.cpp b/dev/WebView2/WebView2.cpp index a930ea5547..ee14e3b758 100644 --- a/dev/WebView2/WebView2.cpp +++ b/dev/WebView2/WebView2.cpp @@ -430,7 +430,7 @@ void WebView2::ResetPointerHelper(const winrt::PointerRoutedEventArgs& args) bool WebView2::ShouldNavigate(const winrt::Uri& uri) { - return uri != nullptr && uri.ToString() != m_stopNavigateOnUriChanged; + return uri != nullptr && uri.RawUri() != m_stopNavigateOnUriChanged; } winrt::IAsyncAction WebView2::OnSourceChanged(winrt::Uri providedUri) diff --git "a/test/MUXControlsTestApp/Assets/SimplePageWithNon\303\205sci\303\255.html" "b/test/MUXControlsTestApp/Assets/SimplePageWithNon\303\205sci\303\255.html" new file mode 100644 index 0000000000..bf9c96a1a1 --- /dev/null +++ "b/test/MUXControlsTestApp/Assets/SimplePageWithNon\303\205sci\303\255.html" @@ -0,0 +1,29 @@ + + + + Simple Page With NonAscii + + + + +

Non-Ascii Page


+ There's a URI with non-ascii characters in the clipboard paste text box that you can copy/paste and navigate to.
+ You can also add non-ascii characters after the 'query' param and reload to see them working there.
+ Here are some non-ascii characters to copy/paste: Å € © ¥ ² → ← Ä Ě ö ñ
+
+ Query String =

+ + \ No newline at end of file