REGRESSION: (r254668) [Mac Debug wk2] 21 http/tests/navigation/* tests are crashing...
authorbeidson@apple.com <beidson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 16 Jan 2020 19:17:47 +0000 (19:17 +0000)
committerbeidson@apple.com <beidson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 16 Jan 2020 19:17:47 +0000 (19:17 +0000)
https://bugs.webkit.org/show_bug.cgi?id=206357

Unreviewed followup to r254668 to fix tests.

ASSERT is no longer valid.
Also, having the magic constant "1" in code is mysterious. Make it properly named everywhere.

* Shared/ContentWorldShared.h: Copied from Source/WebKit/UIProcess/API/APIUserContentWorld.cpp.
* UIProcess/API/APIContentWorld.cpp:
(API::ContentWorld::pageContentWorld):
* UIProcess/API/APIUserContentWorld.cpp:
(API::UserContentWorld::generateIdentifier):
(API::UserContentWorld::UserContentWorld):
* UIProcess/API/APIUserContentWorld.h:
* WebKit.xcodeproj/project.pbxproj:
* WebProcess/UserContent/WebUserContentController.cpp:
(WebKit::WebUserContentController::addUserContentWorld):

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

Source/WebKit/ChangeLog
Source/WebKit/Shared/ContentWorldShared.h [new file with mode: 0644]
Source/WebKit/UIProcess/API/APIContentWorld.cpp
Source/WebKit/UIProcess/API/APIUserContentWorld.cpp
Source/WebKit/UIProcess/API/APIUserContentWorld.h
Source/WebKit/WebKit.xcodeproj/project.pbxproj
Source/WebKit/WebProcess/UserContent/WebUserContentController.cpp

index 1f7b182..4c17253 100644 (file)
@@ -1,3 +1,24 @@
+2020-01-16  Brady Eidson  <beidson@apple.com>
+
+        REGRESSION: (r254668) [Mac Debug wk2] 21 http/tests/navigation/* tests are crashing with ASSERTION FAILED: world.first != 1.
+        https://bugs.webkit.org/show_bug.cgi?id=206357
+
+        Unreviewed followup to r254668 to fix tests.
+
+        ASSERT is no longer valid.
+        Also, having the magic constant "1" in code is mysterious. Make it properly named everywhere.
+        
+        * Shared/ContentWorldShared.h: Copied from Source/WebKit/UIProcess/API/APIUserContentWorld.cpp.
+        * UIProcess/API/APIContentWorld.cpp:
+        (API::ContentWorld::pageContentWorld):
+        * UIProcess/API/APIUserContentWorld.cpp:
+        (API::UserContentWorld::generateIdentifier):
+        (API::UserContentWorld::UserContentWorld):
+        * UIProcess/API/APIUserContentWorld.h:
+        * WebKit.xcodeproj/project.pbxproj:
+        * WebProcess/UserContent/WebUserContentController.cpp:
+        (WebKit::WebUserContentController::addUserContentWorld):
+
 2020-01-16  youenn fablet  <youenn@apple.com>
 
         Add support for MediaStream video track rendering in GPUProcess
diff --git a/Source/WebKit/Shared/ContentWorldShared.h b/Source/WebKit/Shared/ContentWorldShared.h
new file mode 100644 (file)
index 0000000..1dad6e1
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2020 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
+
+namespace WebKit {
+
+static const uint64_t pageContentWorldIdentifier = 1;
+
+} // namespace WebKit
index 6345476..eeb7d8e 100644 (file)
@@ -27,6 +27,7 @@
 #include "APIContentWorld.h"
 
 #include "APIUserContentWorld.h"
+#include "ContentWorldShared.h"
 
 namespace API {
 
@@ -49,7 +50,7 @@ Ref<ContentWorld> ContentWorld::sharedWorldWithName(const WTF::String& name)
 
 ContentWorld& ContentWorld::pageContentWorld()
 {
-    static NeverDestroyed<RefPtr<ContentWorld>> world(adoptRef(new ContentWorld(API::UserContentWorld::normalWorldIdentifer())));
+    static NeverDestroyed<RefPtr<ContentWorld>> world(adoptRef(new ContentWorld(WebKit::pageContentWorldIdentifier)));
     return *world.get();
 }
 
index a85a15b..3479bd4 100644 (file)
 #include "config.h"
 #include "APIUserContentWorld.h"
 
+#include "ContentWorldShared.h"
+
 namespace API {
 
 uint64_t UserContentWorld::generateIdentifier()
 {
-    static uint64_t identifier = normalWorldIdentifer();
+    static uint64_t identifier = WebKit::pageContentWorldIdentifier;
 
     return ++identifier;
 }
@@ -53,7 +55,7 @@ UserContentWorld::UserContentWorld(const WTF::String& name)
 }
 
 UserContentWorld::UserContentWorld(ForNormalWorldOnly)
-    : m_identifier(normalWorldIdentifer())
+    : m_identifier(WebKit::pageContentWorldIdentifier)
 {
 }
 
index fe9fc54..9ead618 100644 (file)
@@ -43,8 +43,6 @@ public:
     const WTF::String& name() const { return m_name; }
     uint64_t identifier() const { return m_identifier; }
 
-    static uint64_t normalWorldIdentifer() { return 1; };
-
 private:
     friend class ContentWorld;
 
index 11fcdc6..84b090f 100644 (file)
                51240EC0220B694C005CFC63 /* NetworkResourceLoadMap.h in Headers */ = {isa = PBXBuildFile; fileRef = 51240EBE220B6947005CFC63 /* NetworkResourceLoadMap.h */; };
                512935D81288D19400A4B695 /* WebContextMenuItem.h in Headers */ = {isa = PBXBuildFile; fileRef = 512935D61288D19400A4B695 /* WebContextMenuItem.h */; };
                512935E41288D97800A4B695 /* InjectedBundlePageContextMenuClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 512935E21288D97800A4B695 /* InjectedBundlePageContextMenuClient.h */; };
+               5129EB1223D0DE7B00AF1CD7 /* ContentWorldShared.h in Headers */ = {isa = PBXBuildFile; fileRef = 5129EB1123D0DE7800AF1CD7 /* ContentWorldShared.h */; };
                512E34E5130B4D0500ABD19A /* WKApplicationCacheManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 517A33B4130B308C00F80CB5 /* WKApplicationCacheManager.h */; settings = {ATTRIBUTES = (Private, ); }; };
                512F589712A8838800629530 /* AuthenticationChallengeProxy.h in Headers */ = {isa = PBXBuildFile; fileRef = 512F588F12A8838800629530 /* AuthenticationChallengeProxy.h */; };
                512F589912A8838800629530 /* AuthenticationDecisionListener.h in Headers */ = {isa = PBXBuildFile; fileRef = 512F589112A8838800629530 /* AuthenticationDecisionListener.h */; };
                512935D61288D19400A4B695 /* WebContextMenuItem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebContextMenuItem.h; sourceTree = "<group>"; };
                512935E11288D97800A4B695 /* InjectedBundlePageContextMenuClient.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InjectedBundlePageContextMenuClient.cpp; sourceTree = "<group>"; };
                512935E21288D97800A4B695 /* InjectedBundlePageContextMenuClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InjectedBundlePageContextMenuClient.h; sourceTree = "<group>"; };
+               5129EB1123D0DE7800AF1CD7 /* ContentWorldShared.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ContentWorldShared.h; sourceTree = "<group>"; };
                512F588E12A8838800629530 /* AuthenticationChallengeProxy.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AuthenticationChallengeProxy.cpp; sourceTree = "<group>"; };
                512F588F12A8838800629530 /* AuthenticationChallengeProxy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AuthenticationChallengeProxy.h; sourceTree = "<group>"; };
                512F589012A8838800629530 /* AuthenticationDecisionListener.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AuthenticationDecisionListener.cpp; sourceTree = "<group>"; };
                                BCF18637167D071E00A1A85A /* CacheModel.cpp */,
                                BC3065F91259344E00E71278 /* CacheModel.h */,
                                9BC59D6C1EFCCCB6001E8D09 /* CallbackID.h */,
+                               5129EB1123D0DE7800AF1CD7 /* ContentWorldShared.h */,
                                5106D7BF18BDBE73000AB166 /* ContextMenuContextData.cpp */,
                                5106D7C018BDBE73000AB166 /* ContextMenuContextData.h */,
                                99F642D21FABE378009621E9 /* CoordinateSystem.h */,
                                37BEC4E119491486008B4286 /* CompletionHandlerCallChecker.h in Headers */,
                                37C4E9F6131C6E7E0029BD5A /* config.h in Headers */,
                                BC032DAB10F437D10058C15A /* Connection.h in Headers */,
+                               5129EB1223D0DE7B00AF1CD7 /* ContentWorldShared.h in Headers */,
                                5106D7C418BDBE73000AB166 /* ContextMenuContextData.h in Headers */,
                                37C21CAE1E994C0C0029D5F9 /* CorePredictionSPI.h in Headers */,
                                B878B615133428DC006888E9 /* CorrectionPanel.h in Headers */,
index 6ec6721..276f81b 100644 (file)
@@ -26,6 +26,7 @@
 #include "config.h"
 #include "WebUserContentController.h"
 
+#include "ContentWorldShared.h"
 #include "DataReference.h"
 #include "FrameInfoData.h"
 #include "InjectUserScriptImmediately.h"
@@ -103,7 +104,8 @@ InjectedBundleScriptWorld* WebUserContentController::worldForIdentifier(uint64_t
 void WebUserContentController::addUserContentWorld(const std::pair<uint64_t, String>& world)
 {
     ASSERT(world.first);
-    ASSERT(world.first != 1);
+    if (world.first == pageContentWorldIdentifier)
+        return;
 
     worldMap().ensure(world.first, [&] {
 #if PLATFORM(GTK) || PLATFORM(WPE)
@@ -111,9 +113,9 @@ void WebUserContentController::addUserContentWorld(const std::pair<uint64_t, Str
         // use the existing world created by the web extension if any. The world name is used
         // as the identifier.
         if (auto* existingWorld = InjectedBundleScriptWorld::find(world.second))
-            return std::make_pair(Ref<InjectedBundleScriptWorld>(*existingWorld), 1);
+            return std::make_pair(Ref<InjectedBundleScriptWorld>(*existingWorld), pageContentWorldIdentifier);
 #endif
-        return std::make_pair(InjectedBundleScriptWorld::create(world.second), 1);
+        return std::make_pair(InjectedBundleScriptWorld::create(world.second), pageContentWorldIdentifier);
     });
 }