Title: [237814] tags/Safari-607.1.12.2
Revision
237814
Author
alanc...@apple.com
Date
2018-11-05 10:09:33 -0800 (Mon, 05 Nov 2018)

Log Message

Cherry-pick r237711. rdar://problem/44176965

    In WebCore::ResourceLoadObserver, use document.sessionID().isEphemeral() when possible and check for page existence when not
    https://bugs.webkit.org/show_bug.cgi?id=191119
    <rdar://problem/44176965>

    Reviewed by Chris Dumez.

    Source/WebCore:

    New API test added.

    * loader/ResourceLoadObserver.cpp:
    (WebCore::ResourceLoadObserver::logSubresourceLoading):
    (WebCore::ResourceLoadObserver::logUserInteractionWithReducedTimeResolution):

    Tools:

    This is an API test for a WebKitLegacy WebView that is first closed and then
    _javascript_ is handed a keyboard event.

    * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
    * TestWebKitAPI/Tests/WebKitLegacy/mac/ClosingWebView.mm: Added.
    (-[ClosingWebViewThenSendingItAKeyDownEventLoadDelegate webView:didFinishLoadForFrame:]):
    (-[KeyboardEventListener handleEvent:]):
    (TestWebKitAPI::TEST):

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

Modified Paths

Added Paths

Diff

Modified: tags/Safari-607.1.12.2/Source/WebCore/ChangeLog (237813 => 237814)


--- tags/Safari-607.1.12.2/Source/WebCore/ChangeLog	2018-11-05 18:07:06 UTC (rev 237813)
+++ tags/Safari-607.1.12.2/Source/WebCore/ChangeLog	2018-11-05 18:09:33 UTC (rev 237814)
@@ -1,3 +1,49 @@
+2018-11-05  Alan Coon  <alanc...@apple.com>
+
+        Cherry-pick r237711. rdar://problem/44176965
+
+    In WebCore::ResourceLoadObserver, use document.sessionID().isEphemeral() when possible and check for page existence when not
+    https://bugs.webkit.org/show_bug.cgi?id=191119
+    <rdar://problem/44176965>
+    
+    Reviewed by Chris Dumez.
+    
+    Source/WebCore:
+    
+    New API test added.
+    
+    * loader/ResourceLoadObserver.cpp:
+    (WebCore::ResourceLoadObserver::logSubresourceLoading):
+    (WebCore::ResourceLoadObserver::logUserInteractionWithReducedTimeResolution):
+    
+    Tools:
+    
+    This is an API test for a WebKitLegacy WebView that is first closed and then
+    _javascript_ is handed a keyboard event.
+    
+    * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+    * TestWebKitAPI/Tests/WebKitLegacy/mac/ClosingWebView.mm: Added.
+    (-[ClosingWebViewThenSendingItAKeyDownEventLoadDelegate webView:didFinishLoadForFrame:]):
+    (-[KeyboardEventListener handleEvent:]):
+    (TestWebKitAPI::TEST):
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@237711 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2018-11-01  John Wilander  <wilan...@apple.com>
+
+            In WebCore::ResourceLoadObserver, use document.sessionID().isEphemeral() when possible and check for page existence when not
+            https://bugs.webkit.org/show_bug.cgi?id=191119
+            <rdar://problem/44176965>
+
+            Reviewed by Chris Dumez.
+
+            New API test added.
+
+            * loader/ResourceLoadObserver.cpp:
+            (WebCore::ResourceLoadObserver::logSubresourceLoading):
+            (WebCore::ResourceLoadObserver::logUserInteractionWithReducedTimeResolution):
+
 2018-11-02  Alan Coon  <alanc...@apple.com>
 
         Cherry-pick r237721. rdar://problem/45722391

Modified: tags/Safari-607.1.12.2/Source/WebCore/loader/ResourceLoadObserver.cpp (237813 => 237814)


--- tags/Safari-607.1.12.2/Source/WebCore/loader/ResourceLoadObserver.cpp	2018-11-05 18:07:06 UTC (rev 237813)
+++ tags/Safari-607.1.12.2/Source/WebCore/loader/ResourceLoadObserver.cpp	2018-11-05 18:09:33 UTC (rev 237814)
@@ -88,8 +88,11 @@
 {
     ASSERT(frame->page());
 
+    if (!frame)
+        return;
+
     auto* page = frame->page();
-    if (!shouldLog(page->usesEphemeralSession()))
+    if (!page || !shouldLog(page->usesEphemeralSession()))
         return;
 
     bool isRedirect = is3xxRedirect(redirectResponse);
@@ -157,9 +160,7 @@
 
 void ResourceLoadObserver::logUserInteractionWithReducedTimeResolution(const Document& document)
 {
-    ASSERT(document.page());
-
-    if (!shouldLog(document.page()->usesEphemeralSession()))
+    if (!shouldLog(document.sessionID().isEphemeral()))
         return;
 
     auto& url = ""

Modified: tags/Safari-607.1.12.2/Tools/ChangeLog (237813 => 237814)


--- tags/Safari-607.1.12.2/Tools/ChangeLog	2018-11-05 18:07:06 UTC (rev 237813)
+++ tags/Safari-607.1.12.2/Tools/ChangeLog	2018-11-05 18:09:33 UTC (rev 237814)
@@ -1,3 +1,52 @@
+2018-11-05  Alan Coon  <alanc...@apple.com>
+
+        Cherry-pick r237711. rdar://problem/44176965
+
+    In WebCore::ResourceLoadObserver, use document.sessionID().isEphemeral() when possible and check for page existence when not
+    https://bugs.webkit.org/show_bug.cgi?id=191119
+    <rdar://problem/44176965>
+    
+    Reviewed by Chris Dumez.
+    
+    Source/WebCore:
+    
+    New API test added.
+    
+    * loader/ResourceLoadObserver.cpp:
+    (WebCore::ResourceLoadObserver::logSubresourceLoading):
+    (WebCore::ResourceLoadObserver::logUserInteractionWithReducedTimeResolution):
+    
+    Tools:
+    
+    This is an API test for a WebKitLegacy WebView that is first closed and then
+    _javascript_ is handed a keyboard event.
+    
+    * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+    * TestWebKitAPI/Tests/WebKitLegacy/mac/ClosingWebView.mm: Added.
+    (-[ClosingWebViewThenSendingItAKeyDownEventLoadDelegate webView:didFinishLoadForFrame:]):
+    (-[KeyboardEventListener handleEvent:]):
+    (TestWebKitAPI::TEST):
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@237711 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2018-11-01  John Wilander  <wilan...@apple.com>
+
+            In WebCore::ResourceLoadObserver, use document.sessionID().isEphemeral() when possible and check for page existence when not
+            https://bugs.webkit.org/show_bug.cgi?id=191119
+            <rdar://problem/44176965>
+
+            Reviewed by Chris Dumez.
+
+            This is an API test for a WebKitLegacy WebView that is first closed and then
+            _javascript_ is handed a keyboard event.
+
+            * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+            * TestWebKitAPI/Tests/WebKitLegacy/mac/ClosingWebView.mm: Added.
+            (-[ClosingWebViewThenSendingItAKeyDownEventLoadDelegate webView:didFinishLoadForFrame:]):
+            (-[KeyboardEventListener handleEvent:]):
+            (TestWebKitAPI::TEST):
+
 2018-11-02  Babak Shafiei  <bshaf...@apple.com>
 
         Revert r237547. rdar://problem/45767917

Modified: tags/Safari-607.1.12.2/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (237813 => 237814)


--- tags/Safari-607.1.12.2/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj	2018-11-05 18:07:06 UTC (rev 237813)
+++ tags/Safari-607.1.12.2/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj	2018-11-05 18:09:33 UTC (rev 237814)
@@ -309,6 +309,7 @@
 		636353A71E98665D0009F8AF /* GeolocationGetCurrentPositionResult.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 636353A61E9861940009F8AF /* GeolocationGetCurrentPositionResult.html */; };
 		63A61B8B1FAD251100F06885 /* display-mode.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 63A61B8A1FAD204D00F06885 /* display-mode.html */; };
 		63F668221F97F7F90032EE51 /* ApplicationManifest.mm in Sources */ = {isa = PBXBuildFile; fileRef = 63F668201F97C3AA0032EE51 /* ApplicationManifest.mm */; };
+		6B306106218A372900F5A802 /* ClosingWebView.mm in Sources */ = {isa = PBXBuildFile; fileRef = 6B306105218A372900F5A802 /* ClosingWebView.mm */; };
 		6B9ABE122086952F00D75DE6 /* HTTPParsers.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6B9ABE112086952F00D75DE6 /* HTTPParsers.cpp */; };
 		6BFD294C1D5E6C1D008EC968 /* HashCountedSet.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7A38D7E51C752D5F004F157D /* HashCountedSet.cpp */; };
 		751B05D61F8EAC410028A09E /* DatabaseTrackerTest.mm in Sources */ = {isa = PBXBuildFile; fileRef = 751B05D51F8EAC1A0028A09E /* DatabaseTrackerTest.mm */; };
@@ -1615,6 +1616,7 @@
 		636353A61E9861940009F8AF /* GeolocationGetCurrentPositionResult.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = GeolocationGetCurrentPositionResult.html; sourceTree = "<group>"; };
 		63A61B8A1FAD204D00F06885 /* display-mode.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = "display-mode.html"; sourceTree = "<group>"; };
 		63F668201F97C3AA0032EE51 /* ApplicationManifest.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = ApplicationManifest.mm; sourceTree = "<group>"; };
+		6B306105218A372900F5A802 /* ClosingWebView.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = ClosingWebView.mm; sourceTree = "<group>"; };
 		6B9ABE112086952F00D75DE6 /* HTTPParsers.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = HTTPParsers.cpp; sourceTree = "<group>"; };
 		751B05D51F8EAC1A0028A09E /* DatabaseTrackerTest.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = DatabaseTrackerTest.mm; sourceTree = "<group>"; };
 		754CEC801F6722DC00D0039A /* AutoFillAvailable.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = AutoFillAvailable.mm; sourceTree = "<group>"; };
@@ -2634,6 +2636,7 @@
 			isa = PBXGroup;
 			children = (
 				9BD5111B1FE8E11600D2B630 /* AccessingPastedImage.mm */,
+				6B306105218A372900F5A802 /* ClosingWebView.mm */,
 			);
 			path = mac;
 			sourceTree = "<group>";
@@ -3745,6 +3748,7 @@
 				7CCE7EE51A411AE600447C4C /* CloseThenTerminate.cpp in Sources */,
 				CDF92237216D186400647AA7 /* CloseWebViewAfterEnterFullscreen.mm in Sources */,
 				CDF0B78A216D48DC00421ECC /* CloseWebViewDuringEnterFullscreen.mm in Sources */,
+				6B306106218A372900F5A802 /* ClosingWebView.mm in Sources */,
 				7C83E0BA1D0A64FB00FEBCF3 /* Coding.mm in Sources */,
 				7C3965061CDD74F90094DBB8 /* Color.cpp in Sources */,
 				7C3DB8E41D12129B00AE8CC3 /* CommandBackForward.mm in Sources */,

Added: tags/Safari-607.1.12.2/Tools/TestWebKitAPI/Tests/WebKitLegacy/mac/ClosingWebView.mm (0 => 237814)


--- tags/Safari-607.1.12.2/Tools/TestWebKitAPI/Tests/WebKitLegacy/mac/ClosingWebView.mm	                        (rev 0)
+++ tags/Safari-607.1.12.2/Tools/TestWebKitAPI/Tests/WebKitLegacy/mac/ClosingWebView.mm	2018-11-05 18:09:33 UTC (rev 237814)
@@ -0,0 +1,103 @@
+/*
+ * Copyright (C) 2018 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.
+ */
+
+#import "config.h"
+#import "PlatformUtilities.h"
+#import "WTFStringUtilities.h"
+
+#import <Carbon/Carbon.h>
+#import <_javascript_Core/JSContext.h>
+#import <_javascript_Core/JSExport.h>
+#import <WebKit/WebHTMLView.h>
+#import <WebKit/WebViewPrivate.h>
+#import <wtf/RetainPtr.h>
+
+#if JSC_OBJC_API_ENABLED
+
+static bool didFinishLoad = false;
+static RetainPtr<WebView> webView;
+
+@interface ClosingWebViewThenSendingItAKeyDownEventLoadDelegate : NSObject <WebFrameLoadDelegate>
+@end
+
+@implementation ClosingWebViewThenSendingItAKeyDownEventLoadDelegate
+- (void)webView:(WebView *)sender didFinishLoadForFrame:(WebFrame *)frame
+{
+    didFinishLoad = true;
+}
+@end
+
+@interface KeyboardEventListener : NSObject <DOMEventListener>
+@end
+
+@implementation KeyboardEventListener
+- (void)handleEvent:(DOMEvent *)event
+{
+    if ([event isKindOfClass:[DOMKeyboardEvent class]])
+        [webView _close];
+}
+@end
+
+namespace TestWebKitAPI {
+
+TEST(WebKitLegacy, ClosingWebViewThenSendingItAKeyDownEvent)
+{
+    webView = adoptNS([[WebView alloc] initWithFrame:NSMakeRect(0, 0, 400, 400) frameName:nil groupName:nil]);
+    auto* webHTMLView = (WebHTMLView *)[[[webView mainFrame] frameView] documentView];
+    
+    EXPECT_TRUE([webView respondsToSelector:@selector(_close)]);
+    EXPECT_TRUE([webHTMLView respondsToSelector:@selector(keyDown:)]);
+    EXPECT_TRUE([webHTMLView respondsToSelector:@selector(keyUp:)]);
+
+    auto loadDelegate = adoptNS([[ClosingWebViewThenSendingItAKeyDownEventLoadDelegate alloc] init]);
+    webView.get().frameLoadDelegate = loadDelegate.get();
+    
+    [[webView mainFrame] loadHTMLString:@"<html><body contenteditable><script>function addKeyPressHandler() { document.body.addEventListener('keypress', function(event) { event.preventDefault(); }, true) }; document.body.focus();</script></body></html>" baseURL:nil];
+
+    Util::run(&didFinishLoad);
+
+    // First, add a native event listener that closes the WebView.
+    [[[webView mainFrameDocument] body] addEventListener:@"keypress" listener:[[KeyboardEventListener alloc] init] useCapture:NO];
+
+    // Second, add a _javascript_ event handler that consumes the event.
+    [[[webView mainFrame] _javascript_Context] evaluateScript:@"addKeyPressHandler()"];
+
+    // Finally, fire an event that triggers both handlers. This should not crash.
+    NSEvent *spaceBarDown = [NSEvent keyEventWithType:NSEventTypeKeyDown
+                                             location:NSMakePoint(5, 5)
+                                        modifierFlags:0
+                                            timestamp:GetCurrentEventTime()
+                                         windowNumber:[[webView window] windowNumber]
+                                              context:[NSGraphicsContext currentContext]
+                                           characters:@" "
+                          charactersIgnoringModifiers:@" "
+                                            isARepeat:NO
+                                              keyCode:0x31];
+    [webHTMLView keyDown:spaceBarDown];
+}
+
+} // namespace TestWebKitAPI
+
+#endif // ENABLE(JSC_OBJC_API)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to