<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[205798] branches/safari-602-branch</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/205798">205798</a></dd>
<dt>Author</dt> <dd>bshafiei@apple.com</dd>
<dt>Date</dt> <dd>2016-09-12 00:53:52 -0700 (Mon, 12 Sep 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>Merge <a href="http://trac.webkit.org/projects/webkit/changeset/205783">r205783</a>. rdar://problem/28229756</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#branchessafari602branchSourceWebKit2ChangeLog">branches/safari-602-branch/Source/WebKit2/ChangeLog</a></li>
<li><a href="#branchessafari602branchSourceWebKit2UIProcessAPICocoa_WKThumbnailViewh">branches/safari-602-branch/Source/WebKit2/UIProcess/API/Cocoa/_WKThumbnailView.h</a></li>
<li><a href="#branchessafari602branchSourceWebKit2UIProcessAPICocoa_WKThumbnailViewmm">branches/safari-602-branch/Source/WebKit2/UIProcess/API/Cocoa/_WKThumbnailView.mm</a></li>
<li><a href="#branchessafari602branchToolsChangeLog">branches/safari-602-branch/Tools/ChangeLog</a></li>
<li><a href="#branchessafari602branchToolsTestWebKitAPITestWebKitAPIxcodeprojprojectpbxproj">branches/safari-602-branch/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#branchessafari602branchToolsTestWebKitAPITestsWebKit2WKThumbnailViewmm">branches/safari-602-branch/Tools/TestWebKitAPI/Tests/WebKit2/WKThumbnailView.mm</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="branchessafari602branchSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: branches/safari-602-branch/Source/WebKit2/ChangeLog (205797 => 205798)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-602-branch/Source/WebKit2/ChangeLog        2016-09-12 07:53:49 UTC (rev 205797)
+++ branches/safari-602-branch/Source/WebKit2/ChangeLog        2016-09-12 07:53:52 UTC (rev 205798)
</span><span class="lines">@@ -1,5 +1,23 @@
</span><span class="cx"> 2016-09-12  Babak Shafiei  &lt;bshafiei@apple.com&gt;
</span><span class="cx"> 
</span><ins>+        Merge r205783. rdar://problem/28229756
+
+    2016-09-09  Tim Horton  &lt;timothy_horton@apple.com&gt;
+
+            WKThumbnailView should expose a mode where it can be reparented without resnapshotting
+            https://bugs.webkit.org/show_bug.cgi?id=161828
+            &lt;rdar://problem/28229756&gt;
+
+            Reviewed by Alex Christensen.
+
+            * UIProcess/API/Cocoa/_WKThumbnailView.h:
+            * UIProcess/API/Cocoa/_WKThumbnailView.mm:
+            (-[_WKThumbnailView initWithFrame:fromWKView:]):
+            (-[_WKThumbnailView _viewWasUnparented]):
+            Add such a mode. Bail from snapshot teardown when unparented if it is on.
+
+2016-09-12  Babak Shafiei  &lt;bshafiei@apple.com&gt;
+
</ins><span class="cx">         Merge r205765. rdar://problem/28033492
</span><span class="cx"> 
</span><span class="cx">     2016-09-09  Tim Horton  &lt;timothy_horton@apple.com&gt;
</span></span></pre></div>
<a id="branchessafari602branchSourceWebKit2UIProcessAPICocoa_WKThumbnailViewh"></a>
<div class="modfile"><h4>Modified: branches/safari-602-branch/Source/WebKit2/UIProcess/API/Cocoa/_WKThumbnailView.h (205797 => 205798)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-602-branch/Source/WebKit2/UIProcess/API/Cocoa/_WKThumbnailView.h        2016-09-12 07:53:49 UTC (rev 205797)
+++ branches/safari-602-branch/Source/WebKit2/UIProcess/API/Cocoa/_WKThumbnailView.h        2016-09-12 07:53:52 UTC (rev 205798)
</span><span class="lines">@@ -42,6 +42,9 @@
</span><span class="cx"> @property (nonatomic, readonly) CGSize snapshotSize;
</span><span class="cx"> @property (nonatomic) BOOL exclusivelyUsesSnapshot;
</span><span class="cx"> 
</span><ins>+// Defaults to NO.
+@property (nonatomic) BOOL shouldKeepSnapshotWhenRemovedFromSuperview;
+
</ins><span class="cx"> // This should be removed when all clients go away; it is always YES now.
</span><span class="cx"> @property (nonatomic) BOOL usesSnapshot;
</span><span class="cx"> 
</span></span></pre></div>
<a id="branchessafari602branchSourceWebKit2UIProcessAPICocoa_WKThumbnailViewmm"></a>
<div class="modfile"><h4>Modified: branches/safari-602-branch/Source/WebKit2/UIProcess/API/Cocoa/_WKThumbnailView.mm (205797 => 205798)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-602-branch/Source/WebKit2/UIProcess/API/Cocoa/_WKThumbnailView.mm        2016-09-12 07:53:49 UTC (rev 205797)
+++ branches/safari-602-branch/Source/WebKit2/UIProcess/API/Cocoa/_WKThumbnailView.mm        2016-09-12 07:53:52 UTC (rev 205798)
</span><span class="lines">@@ -59,6 +59,7 @@
</span><span class="cx"> @synthesize snapshotSize=_snapshotSize;
</span><span class="cx"> @synthesize _waitingForSnapshot=_waitingForSnapshot;
</span><span class="cx"> @synthesize exclusivelyUsesSnapshot=_exclusivelyUsesSnapshot;
</span><ins>+@synthesize shouldKeepSnapshotWhenRemovedFromSuperview=_shouldKeepSnapshotWhenRemovedFromSuperview;
</ins><span class="cx"> 
</span><span class="cx"> - (instancetype)initWithFrame:(NSRect)frame fromWKView:(WKView *)wkView
</span><span class="cx"> {
</span><span class="lines">@@ -109,6 +110,9 @@
</span><span class="cx">         _webPageProxy-&gt;setMayStartMediaWhenInWindow(_originalMayStartMediaWhenInWindow);
</span><span class="cx">     }
</span><span class="cx"> 
</span><ins>+    if (_shouldKeepSnapshotWhenRemovedFromSuperview)
+        return;
+
</ins><span class="cx">     self.layer.contents = nil;
</span><span class="cx">     _lastSnapshotScale = NAN;
</span><span class="cx"> }
</span></span></pre></div>
<a id="branchessafari602branchToolsChangeLog"></a>
<div class="modfile"><h4>Modified: branches/safari-602-branch/Tools/ChangeLog (205797 => 205798)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-602-branch/Tools/ChangeLog        2016-09-12 07:53:49 UTC (rev 205797)
+++ branches/safari-602-branch/Tools/ChangeLog        2016-09-12 07:53:52 UTC (rev 205798)
</span><span class="lines">@@ -1,3 +1,23 @@
</span><ins>+2016-09-12  Babak Shafiei  &lt;bshafiei@apple.com&gt;
+
+        Merge r205783. rdar://problem/28229756
+
+    2016-09-09  Tim Horton  &lt;timothy_horton@apple.com&gt;
+
+            WKThumbnailView should expose a mode where it can be reparented without resnapshotting
+            https://bugs.webkit.org/show_bug.cgi?id=161828
+            &lt;rdar://problem/28229756&gt;
+
+            Reviewed by Alex Christensen.
+
+            * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+            * TestWebKitAPI/Tests/WebKit2/WKThumbnailView.mm: Added.
+            (-[SnapshotSizeObserver observeValueForKeyPath:ofObject:change:context:]):
+            (TestWebKitAPI::didFinishLoadForFrame):
+            (TestWebKitAPI::setPageLoaderClient):
+            (TestWebKitAPI::TEST):
+            Add a test ensuring that this behaves correctly.
+
</ins><span class="cx"> 2016-09-09  Babak Shafiei  &lt;bshafiei@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Merge r205417. rdar://problem/28018438
</span></span></pre></div>
<a id="branchessafari602branchToolsTestWebKitAPITestWebKitAPIxcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: branches/safari-602-branch/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (205797 => 205798)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-602-branch/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj        2016-09-12 07:53:49 UTC (rev 205797)
+++ branches/safari-602-branch/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj        2016-09-12 07:53:52 UTC (rev 205798)
</span><span class="lines">@@ -49,6 +49,7 @@
</span><span class="cx">                 297234B7173AFAC700983601 /* CustomProtocolsInvalidScheme_Bundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 297234B5173AFAC700983601 /* CustomProtocolsInvalidScheme_Bundle.cpp */; };
</span><span class="cx">                 2D00065F1C1F589A0088E6A7 /* WKPDFViewResizeCrash.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2D00065D1C1F58940088E6A7 /* WKPDFViewResizeCrash.mm */; };
</span><span class="cx">                 2D1646E21D1862CD00015A1A /* DeferredViewInWindowStateChange.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2D1646E11D1862CD00015A1A /* DeferredViewInWindowStateChange.mm */; };
</span><ins>+                2D4CF8BD1D8360CC0001CE8D /* WKThumbnailView.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2D4CF8BC1D8360CC0001CE8D /* WKThumbnailView.mm */; };
</ins><span class="cx">                 2D51A0C71C8BF00C00765C45 /* DOMHTMLVideoElementWrapper.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2D51A0C51C8BF00400765C45 /* DOMHTMLVideoElementWrapper.mm */; };
</span><span class="cx">                 2DC4CF771D2D9DD800ECCC94 /* DataDetection.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2DC4CF761D2D9DD800ECCC94 /* DataDetection.mm */; };
</span><span class="cx">                 2DD7D3AF178227B30026E1E3 /* lots-of-text-vertical-lr.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 2DD7D3AE178227AC0026E1E3 /* lots-of-text-vertical-lr.html */; };
</span><span class="lines">@@ -720,6 +721,7 @@
</span><span class="cx">                 2D00065D1C1F58940088E6A7 /* WKPDFViewResizeCrash.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKPDFViewResizeCrash.mm; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 2D1646E11D1862CD00015A1A /* DeferredViewInWindowStateChange.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = DeferredViewInWindowStateChange.mm; path = WebKit2/DeferredViewInWindowStateChange.mm; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 2D1FE0AF1AD465C1006CD9E6 /* FixedLayoutSize.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = FixedLayoutSize.mm; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><ins>+                2D4CF8BC1D8360CC0001CE8D /* WKThumbnailView.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = WKThumbnailView.mm; path = WebKit2/WKThumbnailView.mm; sourceTree = &quot;&lt;group&gt;&quot;; };
</ins><span class="cx">                 2D51A0C51C8BF00400765C45 /* DOMHTMLVideoElementWrapper.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DOMHTMLVideoElementWrapper.mm; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 2D640B5417875DFF00BFAF99 /* ScrollPinningBehaviors.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ScrollPinningBehaviors.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 2D8104CB1BEC13E70020DA46 /* FindInPage.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = FindInPage.mm; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="lines">@@ -1465,6 +1467,7 @@
</span><span class="cx">                                 2943BE84161DFEB800999E3D /* UserContentTest.mm */,
</span><span class="cx">                                 BC3C4C7D14587AA60025FB62 /* WKBrowsingContextGroupTest.mm */,
</span><span class="cx">                                 BC3C4C7014575B6A0025FB62 /* WKBrowsingContextLoadDelegateTest.mm */,
</span><ins>+                                2D4CF8BC1D8360CC0001CE8D /* WKThumbnailView.mm */,
</ins><span class="cx">                         );
</span><span class="cx">                         name = &quot;WebKit2 Objective-C&quot;;
</span><span class="cx">                         sourceTree = &quot;&lt;group&gt;&quot;;
</span><span class="lines">@@ -2345,6 +2348,7 @@
</span><span class="cx">                                 7CCE7F181A411AE600447C4C /* UserMessage.cpp in Sources */,
</span><span class="cx">                                 0F139E771A423A5B00F590F5 /* WeakObjCPtr.mm in Sources */,
</span><span class="cx">                                 7CCE7F191A411AE600447C4C /* WebArchive.cpp in Sources */,
</span><ins>+                                2D4CF8BD1D8360CC0001CE8D /* WKThumbnailView.mm in Sources */,
</ins><span class="cx">                                 7CCE7F1A1A411AE600447C4C /* WebCoreStatisticsWithNoWebProcess.cpp in Sources */,
</span><span class="cx">                                 7CCE7EAB1A411A2400447C4C /* WebKitAgnosticTest.mm in Sources */,
</span><span class="cx">                                 7C83E03A1D0A602700FEBCF3 /* UtilitiesCocoa.mm in Sources */,
</span></span></pre></div>
<a id="branchessafari602branchToolsTestWebKitAPITestsWebKit2WKThumbnailViewmm"></a>
<div class="addfile"><h4>Added: branches/safari-602-branch/Tools/TestWebKitAPI/Tests/WebKit2/WKThumbnailView.mm (0 => 205798)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-602-branch/Tools/TestWebKitAPI/Tests/WebKit2/WKThumbnailView.mm                                (rev 0)
+++ branches/safari-602-branch/Tools/TestWebKitAPI/Tests/WebKit2/WKThumbnailView.mm        2016-09-12 07:53:52 UTC (rev 205798)
</span><span class="lines">@@ -0,0 +1,125 @@
</span><ins>+/*
+ * 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 &quot;config.h&quot;
+
+#if WK_HAVE_C_SPI &amp;&amp; PLATFORM(MAC) &amp;&amp; WK_API_ENABLED
+
+#import &quot;JavaScriptTest.h&quot;
+#import &quot;PlatformUtilities.h&quot;
+#import &quot;PlatformWebView.h&quot;
+#import &lt;WebKit/WKViewPrivate.h&gt;
+#import &lt;WebKit/_WKThumbnailView.h&gt;
+#import &lt;wtf/RetainPtr.h&gt;
+
+static bool didFinishLoad;
+static bool didTakeSnapshot;
+
+static void *snapshotSizeChangeKVOContext = &amp;snapshotSizeChangeKVOContext;
+
+@interface SnapshotSizeObserver : NSObject
+@end
+
+@implementation SnapshotSizeObserver
+
+- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
+{
+    if (context == snapshotSizeChangeKVOContext) {
+        didTakeSnapshot = true;
+        return;
+    }
+
+    [super observeValueForKeyPath:keyPath ofObject:object change:change context:context];
+}
+
+@end
+
+namespace TestWebKitAPI {
+
+static void didFinishLoadForFrame(WKPageRef, WKFrameRef, WKTypeRef, const void*)
+{
+    didFinishLoad = true;
+}
+
+static void setPageLoaderClient(WKPageRef page)
+{
+    WKPageLoaderClientV0 loaderClient;
+    memset(&amp;loaderClient, 0, sizeof(loaderClient));
+
+    loaderClient.base.version = 0;
+    loaderClient.didFinishLoadForFrame = didFinishLoadForFrame;
+
+    WKPageSetPageLoaderClient(page, &amp;loaderClient.base);
+}
+
+TEST(WebKit2, WKThumbnailViewKeepSnapshotWhenRemovedFromSuperview)
+{
+    WKRetainPtr&lt;WKContextRef&gt; context = adoptWK(Util::createContextForInjectedBundleTest(&quot;MouseMoveAfterCrashTest&quot;));
+
+    PlatformWebView webView(context.get());
+    WKView *wkView = webView.platformView();
+    setPageLoaderClient(webView.page());
+
+    WKRetainPtr&lt;WKURLRef&gt; url(AdoptWK, Util::createURLForResource(&quot;lots-of-text&quot;, &quot;html&quot;));
+    WKPageLoadURL(webView.page(), url.get());
+    Util::run(&amp;didFinishLoad);
+    didFinishLoad = false;
+
+    RetainPtr&lt;_WKThumbnailView&gt; thumbnailView = adoptNS([[_WKThumbnailView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100) fromWKView:wkView]);
+
+    RetainPtr&lt;SnapshotSizeObserver&gt; observer = adoptNS([[SnapshotSizeObserver alloc] init]);
+
+    [thumbnailView addObserver:observer.get() forKeyPath:@&quot;snapshotSize&quot; options:NSKeyValueObservingOptionNew context:snapshotSizeChangeKVOContext];
+
+    [wkView.window.contentView addSubview:thumbnailView.get()];
+    Util::run(&amp;didTakeSnapshot);
+    didTakeSnapshot = false;
+
+    EXPECT_EQ([thumbnailView snapshotSize].width, 800);
+    EXPECT_FALSE([thumbnailView layer].contents == nil);
+    [thumbnailView removeFromSuperview];
+
+    // The snapshot should be removed when unparented.
+    EXPECT_TRUE([thumbnailView layer].contents == nil);
+
+    [wkView.window.contentView addSubview:thumbnailView.get()];
+    Util::run(&amp;didTakeSnapshot);
+    didTakeSnapshot = false;
+
+    [thumbnailView setShouldKeepSnapshotWhenRemovedFromSuperview:YES];
+
+    EXPECT_EQ([thumbnailView snapshotSize].width, 800);
+    EXPECT_FALSE([thumbnailView layer].contents == nil);
+    [thumbnailView removeFromSuperview];
+
+    // This time, the snapshot should remain while unparented, because we unset shouldKeepSnapshotWhenRemovedFromSuperview.
+    EXPECT_FALSE([thumbnailView layer].contents == nil);
+
+    [thumbnailView removeObserver:observer.get() forKeyPath:@&quot;snapshotSize&quot; context:snapshotSizeChangeKVOContext];
+}
+
+} // namespace TestWebKitAPI
+
+#endif
</ins></span></pre>
</div>
</div>

</body>
</html>