Convert IntersectionObserver over to using RuntimeEnabledFeatures so it can be proper...
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 27 Nov 2016 04:21:49 +0000 (04:21 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 27 Nov 2016 04:21:49 +0000 (04:21 +0000)
https://bugs.webkit.org/show_bug.cgi?id=164965

Patch by Sam Weinig <sam@webkit.org> on 2016-11-26
Reviewed by Simon Fraser.

Source/JavaScriptCore:

* runtime/CommonIdentifiers.h:
Add identifiers needed for RuntimeEnabledFeatures.

Source/WebCore:

* bindings/generic/RuntimeEnabledFeatures.cpp:
(WebCore::RuntimeEnabledFeatures::reset):
* bindings/generic/RuntimeEnabledFeatures.h:
(WebCore::RuntimeEnabledFeatures::setIntersectionObserverEnabled):
(WebCore::RuntimeEnabledFeatures::intersectionObserverEnabled):
Add intersection observer setting.

* page/IntersectionObserver.idl:
* page/IntersectionObserverEntry.idl:
Convert to use EnabledAtRuntime extended attribute.

* page/Settings.in:
Remove the old intersection observer setting.

Source/WebKit/mac:

* WebView/WebPreferenceKeysPrivate.h:
* WebView/WebPreferences.mm:
(-[WebPreferences intersectionObserverEnabled]):
(-[WebPreferences setIntersectionObserverEnabled:]):
* WebView/WebPreferencesPrivate.h:
* WebView/WebView.mm:
(-[WebView _preferencesChanged:]):
Add a preference, defaulting to off, for enabling IntersectionObserver.

Source/WebKit2:

* Shared/WebPreferencesDefinitions.h:
* UIProcess/API/C/WKPreferences.cpp:
(WKPreferencesSetIntersectionObserverEnabled):
(WKPreferencesGetIntersectionObserverEnabled):
* UIProcess/API/C/WKPreferencesRefPrivate.h:
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::updatePreferences):
Add a preference, defaulting to off, for enabling IntersectionObserver.

Tools:

* DumpRenderTree/DumpRenderTree.xcodeproj/project.pbxproj:
Add new files.

* DumpRenderTree/TestOptions.h: Added.
* DumpRenderTree/TestOptions.mm: Added.
(parseBooleanTestHeaderValue):
(TestOptions::TestOptions):
Port TestOption parsing from WKTR to DRT.

* DumpRenderTree/mac/DumpRenderTree.mm:
(resetWebPreferencesToConsistentValues):
(resetWebViewToConsistentStateBeforeTesting):
(runTest):
* WebKitTestRunner/TestController.cpp:
Pass TestOptions down to resetWebPreferencesToConsistentValues to allow setting
preferences conditionally.

(WTR::TestController::resetPreferencesToConsistentValues):
(WTR::updateTestOptionsFromTestHeader):
* WebKitTestRunner/TestOptions.h:
Add a new test option header, enableIntersectionObserver, to enable IntersectionObserver.

LayoutTests:

* intersection-observer/intersection-observer-entry-interface.html:
* intersection-observer/intersection-observer-interface.html:
* resources/testharnessreport.js:
Switch from enabling IntersectionObserver via internals.settings to using
comment header switches.

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

29 files changed:
LayoutTests/ChangeLog
LayoutTests/intersection-observer/intersection-observer-entry-interface.html
LayoutTests/intersection-observer/intersection-observer-interface.html
LayoutTests/resources/testharnessreport.js
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/runtime/CommonIdentifiers.h
Source/WebCore/ChangeLog
Source/WebCore/bindings/generic/RuntimeEnabledFeatures.cpp
Source/WebCore/bindings/generic/RuntimeEnabledFeatures.h
Source/WebCore/page/IntersectionObserver.idl
Source/WebCore/page/IntersectionObserverEntry.idl
Source/WebCore/page/Settings.in
Source/WebKit/mac/ChangeLog
Source/WebKit/mac/WebView/WebPreferenceKeysPrivate.h
Source/WebKit/mac/WebView/WebPreferences.mm
Source/WebKit/mac/WebView/WebPreferencesPrivate.h
Source/WebKit/mac/WebView/WebView.mm
Source/WebKit2/ChangeLog
Source/WebKit2/Shared/WebPreferencesDefinitions.h
Source/WebKit2/UIProcess/API/C/WKPreferences.cpp
Source/WebKit2/UIProcess/API/C/WKPreferencesRefPrivate.h
Source/WebKit2/WebProcess/WebPage/WebPage.cpp
Tools/ChangeLog
Tools/DumpRenderTree/DumpRenderTree.xcodeproj/project.pbxproj
Tools/DumpRenderTree/TestOptions.h [new file with mode: 0644]
Tools/DumpRenderTree/TestOptions.mm [new file with mode: 0644]
Tools/DumpRenderTree/mac/DumpRenderTree.mm
Tools/WebKitTestRunner/TestController.cpp
Tools/WebKitTestRunner/TestOptions.h

index 4d02394..4c03bad 100644 (file)
@@ -1,3 +1,16 @@
+2016-11-26  Sam Weinig  <sam@webkit.org>
+
+        Convert IntersectionObserver over to using RuntimeEnabledFeatures so it can be properly excluded from script
+        https://bugs.webkit.org/show_bug.cgi?id=164965
+
+        Reviewed by Simon Fraser.
+
+        * intersection-observer/intersection-observer-entry-interface.html:
+        * intersection-observer/intersection-observer-interface.html:
+        * resources/testharnessreport.js:
+        Switch from enabling IntersectionObserver via internals.settings to using 
+        comment header switches.
+
 2016-11-26  Simon Fraser  <simon.fraser@apple.com>
 
         Composited negative z-index elements are hidden behind the body sometimes
index b0649ab..ac815a5 100644 (file)
@@ -1,4 +1,4 @@
-<!DOCTYPE html>
+<!DOCTYPE html><!-- webkit-test-runner [ enableIntersectionObserver=true ] -->
 <head>
     <title>IntersectionObserverEntry interface tests.</title>
     <link rel="author" title="Simon Fraser" href="mailto:simon.fraser@apple.com" />
index 9e1cb78..4a29906 100644 (file)
@@ -1,4 +1,4 @@
-<!DOCTYPE html>
+<!DOCTYPE html><!-- webkit-test-runner [ enableIntersectionObserver=true ] -->
 <head>
     <title>IntersectionObserver interface tests.</title>
     <link rel="author" title="Simon Fraser" href="mailto:simon.fraser@apple.com" />
index d6c5430..5b75b0e 100644 (file)
@@ -90,6 +90,5 @@ if (self.testRunner) {
 
     if (window.internals) {
         internals.setResourceTimingSupport(true);
-        internals.settings.setIntersectionObserverEnabled(true);
     }
 }
index e9b429c..92bb5b9 100644 (file)
@@ -1,3 +1,13 @@
+2016-11-26  Sam Weinig  <sam@webkit.org>
+
+        Convert IntersectionObserver over to using RuntimeEnabledFeatures so it can be properly excluded from script
+        https://bugs.webkit.org/show_bug.cgi?id=164965
+
+        Reviewed by Simon Fraser.
+
+        * runtime/CommonIdentifiers.h:
+        Add identifiers needed for RuntimeEnabledFeatures.
+
 2016-11-23  Zan Dobersek  <zdobersek@igalia.com>
 
         Remove ENABLE_ASSEMBLER_WX_EXCLUSIVE code
index 47a1076..0f7e60a 100644 (file)
@@ -64,6 +64,8 @@
     macro(IDBVersionChangeEvent) \
     macro(Infinity) \
     macro(InputEvent) \
+    macro(IntersectionObserver) \
+    macro(IntersectionObserverEntry) \
     macro(Intl) \
     macro(JSON) \
     macro(Loader) \
index 790bbcd..14d7ff0 100644 (file)
@@ -1,3 +1,24 @@
+2016-11-26  Sam Weinig  <sam@webkit.org>
+
+        Convert IntersectionObserver over to using RuntimeEnabledFeatures so it can be properly excluded from script
+        https://bugs.webkit.org/show_bug.cgi?id=164965
+
+        Reviewed by Simon Fraser.
+
+        * bindings/generic/RuntimeEnabledFeatures.cpp:
+        (WebCore::RuntimeEnabledFeatures::reset):
+        * bindings/generic/RuntimeEnabledFeatures.h:
+        (WebCore::RuntimeEnabledFeatures::setIntersectionObserverEnabled):
+        (WebCore::RuntimeEnabledFeatures::intersectionObserverEnabled):
+        Add intersection observer setting.
+
+        * page/IntersectionObserver.idl:
+        * page/IntersectionObserverEntry.idl:
+        Convert to use EnabledAtRuntime extended attribute.
+
+        * page/Settings.in:
+        Remove the old intersection observer setting.
+
 2016-11-26  Simon Fraser  <simon.fraser@apple.com>
 
         Migrate some layout timer-related code from std::chrono to Seconds and MonotonicTime
index 408eb8f..12ee3cd 100644 (file)
@@ -109,7 +109,9 @@ void RuntimeEnabledFeatures::reset()
 #if ENABLE(CSS_GRID_LAYOUT)
     m_cssGridLayoutEnabled = true;
 #endif
-
+#if ENABLE(INTERSECTION_OBSERVER)
+    m_intersectionObserverEnabled = false;
+#endif
 }
 
 RuntimeEnabledFeatures& RuntimeEnabledFeatures::sharedFeatures()
index 608f159..47219e5 100644 (file)
@@ -227,6 +227,11 @@ public:
     bool isCSSGridLayoutEnabled() const { return m_cssGridLayoutEnabled; }
 #endif
 
+#if ENABLE(INTERSECTION_OBSERVER)
+    void setIntersectionObserverEnabled(bool isEnabled) { m_intersectionObserverEnabled = isEnabled; }
+    bool intersectionObserverEnabled() const { return m_intersectionObserverEnabled; }
+#endif
+
     void setModernMediaControlsEnabled(bool areEnabled) { m_areModernMediaControlsEnabled = areEnabled; }
     bool modernMediaControlsEnabled() const { return m_areModernMediaControlsEnabled; }
 
@@ -353,6 +358,10 @@ private:
     bool m_encryptedMediaAPIEnabled { false };
 #endif
 
+#if ENABLE(INTERSECTION_OBSERVER)
+    bool m_intersectionObserverEnabled { false };
+#endif
+
     friend class WTF::NeverDestroyed<RuntimeEnabledFeatures>;
 };
 
index 61d8b21..757de6e 100644 (file)
@@ -29,7 +29,7 @@
     Conditional=INTERSECTION_OBSERVER,
     Constructor(IntersectionObserverCallback callback, optional IntersectionObserverInit options),
     ImplementationLacksVTable,
-    EnabledBySetting=IntersectionObserver
+    EnabledAtRuntime=IntersectionObserver
 ] interface IntersectionObserver {
     readonly attribute Element? root;
     readonly attribute DOMString rootMargin;
index c186505..1b4338b 100644 (file)
@@ -31,7 +31,7 @@ typedef double DOMHighResTimeStamp;
     Conditional=INTERSECTION_OBSERVER,
     Constructor(IntersectionObserverEntryInit intersectionObserverEntryInit),
     ImplementationLacksVTable,
-    EnabledBySetting=IntersectionObserver
+    EnabledAtRuntime=IntersectionObserver
 ] interface IntersectionObserverEntry {
     readonly attribute DOMHighResTimeStamp time;
     readonly attribute DOMRectReadOnly rootBounds;
index 891fe74..51576ba 100644 (file)
@@ -279,7 +279,6 @@ variationFontsEnabled initial=true, setNeedsStyleRecalcInAllFrames=1, conditiona
 
 # Runtime-enabled features
 visualViewportEnabled initial=false, setNeedsStyleRecalcInAllFrames=1
-intersectionObserverEnabled initial=false
 
 inputEventsEnabled initial=true
 
index 1d2e8b2..44c6b4c 100644 (file)
@@ -1,3 +1,19 @@
+2016-11-26  Sam Weinig  <sam@webkit.org>
+
+        Convert IntersectionObserver over to using RuntimeEnabledFeatures so it can be properly excluded from script
+        https://bugs.webkit.org/show_bug.cgi?id=164965
+
+        Reviewed by Simon Fraser.
+
+        * WebView/WebPreferenceKeysPrivate.h:
+        * WebView/WebPreferences.mm:
+        (-[WebPreferences intersectionObserverEnabled]):
+        (-[WebPreferences setIntersectionObserverEnabled:]):
+        * WebView/WebPreferencesPrivate.h:
+        * WebView/WebView.mm:
+        (-[WebView _preferencesChanged:]):
+        Add a preference, defaulting to off, for enabling IntersectionObserver.
+
 2016-11-22  Dan Bernstein  <mitz@apple.com>
 
         [Mac] In Legacy WebKit, pressing an arrow key in editable content doesn’t hide the mouse cursor
index 292d0e9..276b4ed 100644 (file)
 #define WebKitMediaDataLoadsAutomaticallyPreferenceKey @"WebKitMediaDataLoadsAutomatically"
 #define WebKitMockCaptureDevicesEnabledPreferenceKey @"WebKitMockCaptureDevicesEnabled"
 #define WebKitMediaCaptureRequiresSecureConnectionPreferenceKey @"WebKitMediaCaptureRequiresSecureConnection"
-
 #define WebKitAttachmentElementEnabledPreferenceKey @"WebKitAttachmentElementEnabled"
+#define WebKitIntersectionObserverEnabledPreferenceKey @"WebKitIntersectionObserverEnabled"
 
index 99a79c4..ef4fa10 100644 (file)
@@ -2849,6 +2849,16 @@ static NSString *classIBCreatorID = nil;
     [self _setBoolValue:flag forKey:WebKitModernMediaControlsEnabledPreferenceKey];
 }
 
+- (BOOL)intersectionObserverEnabled
+{
+    return [self _boolValueForKey:WebKitIntersectionObserverEnabledPreferenceKey];
+}
+
+- (void)setIntersectionObserverEnabled:(BOOL)flag
+{
+    [self _setBoolValue:flag forKey:WebKitIntersectionObserverEnabledPreferenceKey];
+}
+
 @end
 
 @implementation WebPreferences (WebInternal)
index 5ab34a6..1a3c979 100644 (file)
@@ -518,6 +518,6 @@ extern NSString *WebPreferencesCacheModelChangedInternalNotification;
 @property (nonatomic) BOOL mediaDataLoadsAutomatically;
 @property (nonatomic) BOOL attachmentElementEnabled;
 @property (nonatomic) BOOL allowsInlineMediaPlaybackAfterFullscreen;
-
+@property (nonatomic) BOOL intersectionObserverEnabled;
 
 @end
index 8894d86..dadc262 100644 (file)
@@ -2862,6 +2862,10 @@ static bool needsSelfRetainWhileLoadingQuirk()
     RuntimeEnabledFeatures::sharedFeatures().setWebAnimationsEnabled([preferences webAnimationsEnabled]);
 #endif
 
+#if ENABLE(INTERSECTION_OBSERVER)
+    RuntimeEnabledFeatures::sharedFeatures().setIntersectionObserverEnabled(preferences.intersectionObserverEnabled);
+#endif
+
     NSTimeInterval timeout = [preferences incrementalRenderingSuppressionTimeoutInSeconds];
     if (timeout > 0)
         settings.setIncrementalRenderingSuppressionTimeoutInSeconds(timeout);
index 206daa5..38492d9 100644 (file)
@@ -1,3 +1,19 @@
+2016-11-26  Sam Weinig  <sam@webkit.org>
+
+        Convert IntersectionObserver over to using RuntimeEnabledFeatures so it can be properly excluded from script
+        https://bugs.webkit.org/show_bug.cgi?id=164965
+
+        Reviewed by Simon Fraser.
+
+        * Shared/WebPreferencesDefinitions.h:
+        * UIProcess/API/C/WKPreferences.cpp:
+        (WKPreferencesSetIntersectionObserverEnabled):
+        (WKPreferencesGetIntersectionObserverEnabled):
+        * UIProcess/API/C/WKPreferencesRefPrivate.h:
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::updatePreferences):
+        Add a preference, defaulting to off, for enabling IntersectionObserver.
+
 2016-11-26  Simon Fraser  <simon.fraser@apple.com>
 
         Migrate some layout timer-related code from std::chrono to Seconds and MonotonicTime
index 59b130c..e00d2ee 100644 (file)
     macro(AsyncImageDecodingEnabled, asyncImageDecodingEnabled, Bool, bool, true, "", "") \
     macro(CustomElementsEnabled, customElementsEnabled, Bool, bool, true, "", "") \
     macro(EncryptedMediaAPIEnabled, encryptedMediaAPIEnabled, Bool, bool, false, "", "") \
+    macro(IntersectionObserverEnabled, intersectionObserverEnabled, Bool, bool, false, "Intersection Observer", "Enable Intersection Observer support") \
     \
 
 #define FOR_EACH_WEBKIT_DOUBLE_PREFERENCE(macro) \
index aaf1546..7c6d30a 100644 (file)
@@ -1551,6 +1551,16 @@ bool WKPreferencesGetES6ModulesEnabled(WKPreferencesRef preferencesRef)
     return toImpl(preferencesRef)->es6ModulesEnabled();
 }
 
+void WKPreferencesSetIntersectionObserverEnabled(WKPreferencesRef preferencesRef, bool flag)
+{
+    toImpl(preferencesRef)->setIntersectionObserverEnabled(flag);
+}
+
+bool WKPreferencesGetIntersectionObserverEnabled(WKPreferencesRef preferencesRef)
+{
+    return toImpl(preferencesRef)->intersectionObserverEnabled();
+}
+
 void WKPreferencesSetSelectionPaintingWithoutSelectionGapsEnabled(WKPreferencesRef preferencesRef, bool flag)
 {
     toImpl(preferencesRef)->setSelectionPaintingWithoutSelectionGapsEnabled(flag);
index c487bc5..f17f71b 100644 (file)
@@ -442,6 +442,10 @@ WK_EXPORT bool WKPreferencesGetAllowsPictureInPictureMediaPlayback(WKPreferences
 WK_EXPORT void WKPreferencesSetES6ModulesEnabled(WKPreferencesRef, bool flag);
 WK_EXPORT bool WKPreferencesGetES6ModulesEnabled(WKPreferencesRef);
 
+// Defaults to false
+WK_EXPORT void WKPreferencesSetIntersectionObserverEnabled(WKPreferencesRef, bool flag);
+WK_EXPORT bool WKPreferencesGetIntersectionObserverEnabled(WKPreferencesRef);
+
 #ifdef __cplusplus
 }
 #endif
index c95015f..20966e8 100644 (file)
@@ -3191,6 +3191,10 @@ void WebPage::updatePreferences(const WebPreferencesStore& store)
     RuntimeEnabledFeatures::sharedFeatures().setEncryptedMediaAPIEnabled(store.getBoolValueForKey(WebPreferencesKey::encryptedMediaAPIEnabledKey()));
 #endif
 
+#if ENABLE(INTERSECTION_OBSERVER)
+    RuntimeEnabledFeatures::sharedFeatures().setIntersectionObserverEnabled(store.getBoolValueForKey(WebPreferencesKey::intersectionObserverEnabledKey()));
+#endif
+
     platformPreferencesDidChange(store);
 
     if (m_drawingArea)
index ff506d6..901ffda 100644 (file)
@@ -1,3 +1,32 @@
+2016-11-26  Sam Weinig  <sam@webkit.org>
+
+        Convert IntersectionObserver over to using RuntimeEnabledFeatures so it can be properly excluded from script
+        https://bugs.webkit.org/show_bug.cgi?id=164965
+
+        Reviewed by Simon Fraser.
+
+        * DumpRenderTree/DumpRenderTree.xcodeproj/project.pbxproj:
+        Add new files.
+
+        * DumpRenderTree/TestOptions.h: Added.
+        * DumpRenderTree/TestOptions.mm: Added.
+        (parseBooleanTestHeaderValue):
+        (TestOptions::TestOptions):
+        Port TestOption parsing from WKTR to DRT.
+
+        * DumpRenderTree/mac/DumpRenderTree.mm:
+        (resetWebPreferencesToConsistentValues):
+        (resetWebViewToConsistentStateBeforeTesting):
+        (runTest):
+        * WebKitTestRunner/TestController.cpp:
+        Pass TestOptions down to resetWebPreferencesToConsistentValues to allow setting
+        preferences conditionally.
+
+        (WTR::TestController::resetPreferencesToConsistentValues):
+        (WTR::updateTestOptionsFromTestHeader):
+        * WebKitTestRunner/TestOptions.h:
+        Add a new test option header, enableIntersectionObserver, to enable IntersectionObserver.
+
 2016-11-26  Simon Fraser  <simon.fraser@apple.com>
 
         Migrate some layout timer-related code from std::chrono to Seconds and MonotonicTime
index 48f9432..6d9dc82 100644 (file)
                5DB9AC9E0F722C3600684641 /* WebKitWeightWatcher700.ttf in Copy Font Files */ = {isa = PBXBuildFile; fileRef = 375F09770DAC3CB600C8B4E5 /* WebKitWeightWatcher700.ttf */; };
                5DB9AC9F0F722C3600684641 /* WebKitWeightWatcher800.ttf in Copy Font Files */ = {isa = PBXBuildFile; fileRef = 375F09780DAC3CB600C8B4E5 /* WebKitWeightWatcher800.ttf */; };
                5DB9ACA00F722C3600684641 /* WebKitWeightWatcher900.ttf in Copy Font Files */ = {isa = PBXBuildFile; fileRef = 375F09790DAC3CB600C8B4E5 /* WebKitWeightWatcher900.ttf */; };
+               7CBBC3231DDFCF9A00786B9D /* TestOptions.mm in Sources */ = {isa = PBXBuildFile; fileRef = 7CBBC3211DDFCF9A00786B9D /* TestOptions.mm */; };
                80045AEE147718E7008290A8 /* AccessibilityNotificationHandler.mm in Sources */ = {isa = PBXBuildFile; fileRef = 80045AEC147718E7008290A8 /* AccessibilityNotificationHandler.mm */; };
                8465E2C70FFA8DF2003B8342 /* PixelDumpSupport.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8465E2C60FFA8DF2003B8342 /* PixelDumpSupport.cpp */; };
                9830F31F15C81181005AB206 /* DumpRenderTreeCommon.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9830F31E15C81181005AB206 /* DumpRenderTreeCommon.cpp */; };
                53CBB830134E42F3001CE6A4 /* CyclicRedundancyCheck.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CyclicRedundancyCheck.cpp; sourceTree = "<group>"; };
                53CBB831134E42F3001CE6A4 /* CyclicRedundancyCheck.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CyclicRedundancyCheck.h; sourceTree = "<group>"; };
                5DE8AE4313A2C15800D6A37D /* libWebCoreTestSupport.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; path = libWebCoreTestSupport.dylib; sourceTree = BUILT_PRODUCTS_DIR; };
+               7CBBC3211DDFCF9A00786B9D /* TestOptions.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = TestOptions.mm; sourceTree = "<group>"; };
+               7CBBC3221DDFCF9A00786B9D /* TestOptions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TestOptions.h; sourceTree = "<group>"; };
                80045AEB147718E7008290A8 /* AccessibilityNotificationHandler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AccessibilityNotificationHandler.h; path = mac/AccessibilityNotificationHandler.h; sourceTree = "<group>"; };
                80045AEC147718E7008290A8 /* AccessibilityNotificationHandler.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = AccessibilityNotificationHandler.mm; path = mac/AccessibilityNotificationHandler.mm; sourceTree = "<group>"; };
                8465E2C60FFA8DF2003B8342 /* PixelDumpSupport.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = PixelDumpSupport.cpp; sourceTree = "<group>"; };
                                A134E52F188FC27000901D06 /* DumpRenderTreeMain.mm */,
                                A8B91BF70CF522B4008F91FF /* CheckedMalloc.cpp */,
                                A8B91BF90CF522B4008F91FF /* CheckedMalloc.h */,
+                               7CBBC3211DDFCF9A00786B9D /* TestOptions.mm */,
+                               7CBBC3221DDFCF9A00786B9D /* TestOptions.h */,
                                BC4741290D038A4C0072B006 /* JavaScriptThreading.h */,
                                BCA18C0A0C9B59EF00114369 /* DumpRenderTreeMac.h */,
                                BCA18B730C9B08F100114369 /* DumpRenderTreeDraggingInfo.h */,
                                0F18E6EC1D6B9C070027E547 /* UIScriptContext.cpp in Sources */,
                                0F18E6ED1D6B9C070027E547 /* UIScriptController.cpp in Sources */,
                                0F18E70D1D6BAC8C0027E547 /* UIScriptControllerIOS.mm in Sources */,
+                               7CBBC3231DDFCF9A00786B9D /* TestOptions.mm in Sources */,
                                0F18E70F1D6BACB60027E547 /* UIScriptControllerMac.mm in Sources */,
                                4437730E125CBC3600AAE02C /* WebArchiveDumpSupport.cpp in Sources */,
                                440590711268453800CFD48D /* WebArchiveDumpSupportMac.mm in Sources */,
diff --git a/Tools/DumpRenderTree/TestOptions.h b/Tools/DumpRenderTree/TestOptions.h
new file mode 100644 (file)
index 0000000..c48c06c
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ * 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.
+ */
+
+#pragma once
+
+struct TestOptions {
+    bool enableIntersectionObserver { false };
+
+    TestOptions(NSURL *testURL);
+};
diff --git a/Tools/DumpRenderTree/TestOptions.mm b/Tools/DumpRenderTree/TestOptions.mm
new file mode 100644 (file)
index 0000000..9a9ebd4
--- /dev/null
@@ -0,0 +1,82 @@
+/*
+ * 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 "TestOptions.h"
+
+#include <fstream>
+#include <string>
+
+static bool parseBooleanTestHeaderValue(const std::string& value)
+{
+    if (value == "true")
+        return true;
+    if (value == "false")
+        return false;
+
+    NSLog(@"Found unexpected value '%s' for boolean option. Expected 'true' or 'false'.", value.c_str());
+    return false;
+}
+
+TestOptions::TestOptions(NSURL *testURL)
+{
+    if (![testURL isFileURL])
+        return;
+
+    std::string path = [testURL fileSystemRepresentation];
+
+    std::string options;
+    std::ifstream testFile(path.data());
+    if (!testFile.good())
+        return;
+    getline(testFile, options);
+    std::string beginString("webkit-test-runner [ ");
+    std::string endString(" ]");
+    size_t beginLocation = options.find(beginString);
+    if (beginLocation == std::string::npos)
+        return;
+    size_t endLocation = options.find(endString, beginLocation);
+    if (endLocation == std::string::npos) {
+        NSLog(@"Could not find end of test header in %s", path.c_str());
+        return;
+    }
+    std::string pairString = options.substr(beginLocation + beginString.size(), endLocation - (beginLocation + beginString.size()));
+    size_t pairStart = 0;
+    while (pairStart < pairString.size()) {
+        size_t pairEnd = pairString.find(" ", pairStart);
+        if (pairEnd == std::string::npos)
+            pairEnd = pairString.size();
+        size_t equalsLocation = pairString.find("=", pairStart);
+        if (equalsLocation == std::string::npos) {
+            NSLog(@"Malformed option in test header (could not find '=' character) in %s", path.c_str());
+            break;
+        }
+        auto key = pairString.substr(pairStart, equalsLocation - pairStart);
+        auto value = pairString.substr(equalsLocation + 1, pairEnd - (equalsLocation + 1));
+        if (key == "enableIntersectionObserver")
+            this->enableIntersectionObserver = parseBooleanTestHeaderValue(value);
+        pairStart = pairEnd + 1;
+    }
+}
index e5e4eac..2d76c04 100644 (file)
@@ -49,6 +49,7 @@
 #import "PixelDumpSupport.h"
 #import "PolicyDelegate.h"
 #import "ResourceLoadDelegate.h"
+#import "TestOptions.h"
 #import "TestRunner.h"
 #import "UIDelegate.h"
 #import "WebArchiveDumpSupport.h"
@@ -895,7 +896,7 @@ static NSString *libraryPathForDumpRenderTree()
 }
 
 // Called before each test.
-static void resetWebPreferencesToConsistentValues()
+static void resetWebPreferencesToConsistentValues(const TestOptions& options)
 {
     WebPreferences *preferences = [WebPreferences standardPreferences];
 
@@ -999,6 +1000,8 @@ static void resetWebPreferencesToConsistentValues()
     [preferences setHiddenPageDOMTimerThrottlingEnabled:NO];
     [preferences setHiddenPageCSSAnimationSuspensionEnabled:NO];
 
+    preferences.intersectionObserverEnabled = options.enableIntersectionObserver;
+
     [WebPreferences _clearNetworkLoaderSession];
     [WebPreferences _setCurrentNetworkLoaderSessionCookieAcceptPolicy:NSHTTPCookieAcceptPolicyOnlyFromMainDocumentDomain];
 }
@@ -1818,7 +1821,7 @@ static bool shouldMakeViewportFlexible(const char* pathOrURL)
 }
 #endif
 
-static void resetWebViewToConsistentStateBeforeTesting()
+static void resetWebViewToConsistentStateBeforeTesting(const TestOptions& options)
 {
     WebView *webView = [mainFrame webView];
 #if PLATFORM(IOS)
@@ -1851,7 +1854,7 @@ static void resetWebViewToConsistentStateBeforeTesting()
 
     [WebCache clearCachedCredentials];
     
-    resetWebPreferencesToConsistentValues();
+    resetWebPreferencesToConsistentValues(options);
 
     TestRunner::setSerializeHTTPLoads(false);
     TestRunner::setAllowsAnySSLCertificate(false);
@@ -1985,9 +1988,11 @@ static void runTest(const string& inputLine)
     NSString *informationString = [@"CRASHING TEST: " stringByAppendingString:testPath];
     WKSetCrashReportApplicationSpecificInformation((CFStringRef)informationString);
 
+    TestOptions options(url);
+    resetWebViewToConsistentStateBeforeTesting(options);
+
     const char* testURL([[url absoluteString] UTF8String]);
-    
-    resetWebViewToConsistentStateBeforeTesting();
+
 #if !PLATFORM(IOS)
     changeWindowScaleIfNeeded(testURL);
 #endif
@@ -2096,7 +2101,7 @@ static void runTest(const string& inputLine)
         }
     }
 
-    resetWebViewToConsistentStateBeforeTesting();
+    resetWebViewToConsistentStateBeforeTesting(options);
 
     // Loading an empty request synchronously replaces the document with a blank one, which is necessary
     // to stop timers, WebSockets and other activity that could otherwise spill output into next test's results.
index edeec6c..0a7b15d 100644 (file)
@@ -649,6 +649,7 @@ void TestController::resetPreferencesToConsistentValues(const TestOptions& optio
     WKPreferencesSetInteractiveFormValidationEnabled(preferences, true);
     WKPreferencesSetMockScrollbarsEnabled(preferences, options.useMockScrollbars);
     WKPreferencesSetNeedsSiteSpecificQuirks(preferences, options.needsSiteSpecificQuirks);
+    WKPreferencesSetIntersectionObserverEnabled(preferences, options.enableIntersectionObserver);
 
     static WKStringRef defaultTextEncoding = WKStringCreateWithUTF8CString("ISO-8859-1");
     WKPreferencesSetDefaultTextEncodingName(preferences, defaultTextEncoding);
@@ -954,6 +955,8 @@ static void updateTestOptionsFromTestHeader(TestOptions& testOptions, const std:
             testOptions.ignoresViewportScaleLimits = parseBooleanTestHeaderValue(value);
         if (key == "useCharacterSelectionGranularity")
             testOptions.useCharacterSelectionGranularity = parseBooleanTestHeaderValue(value);
+        if (key == "enableIntersectionObserver")
+            testOptions.enableIntersectionObserver = parseBooleanTestHeaderValue(value);
         pairStart = pairEnd + 1;
     }
 }
index 519e367..052ff20 100644 (file)
@@ -43,6 +43,7 @@ struct TestOptions {
     bool needsSiteSpecificQuirks { false };
     bool ignoresViewportScaleLimits { false };
     bool useCharacterSelectionGranularity { false };
+    bool enableIntersectionObserver { false };
 
     float deviceScaleFactor { 1 };
     Vector<String> overrideLanguages;