Unreviewed, rolling out r244437.
authorryanhaddad@apple.com <ryanhaddad@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 22 Apr 2019 19:51:38 +0000 (19:51 +0000)
committerryanhaddad@apple.com <ryanhaddad@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 22 Apr 2019 19:51:38 +0000 (19:51 +0000)
Still breaks internal tests.

Reverted changeset:

"InjectedBundle parameters often need initialization function
called before unarchiving"
https://bugs.webkit.org/show_bug.cgi?id=189709
https://trac.webkit.org/changeset/244437

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

Source/WebKit/ChangeLog
Source/WebKit/WebProcess/InjectedBundle/API/mac/WKWebProcessPlugIn.h
Source/WebKit/WebProcess/InjectedBundle/InjectedBundle.h
Source/WebKit/WebProcess/InjectedBundle/mac/InjectedBundleMac.mm
Tools/ChangeLog
Tools/TestWebKitAPI/cocoa/WebProcessPlugIn/WebProcessPlugIn.mm

index 6328f1e..f1197d3 100644 (file)
@@ -1,3 +1,16 @@
+2019-04-22  Ryan Haddad  <ryanhaddad@apple.com>
+
+        Unreviewed, rolling out r244437.
+
+        Still breaks internal tests.
+
+        Reverted changeset:
+
+        "InjectedBundle parameters often need initialization function
+        called before unarchiving"
+        https://bugs.webkit.org/show_bug.cgi?id=189709
+        https://trac.webkit.org/changeset/244437
+
 2019-04-22  Chris Dumez  <cdumez@apple.com>
 
         Delayed WebProcessLaunch may break the _relatedWebView SPI
index 769fa9a..8fb4671 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2012-2019 Apple Inc. All rights reserved.
+ * Copyright (C) 2012 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -37,7 +37,6 @@
 - (void)webProcessPlugIn:(WKWebProcessPlugInController *)plugInController initializeWithObject:(id)initializationObject;
 - (void)webProcessPlugIn:(WKWebProcessPlugInController *)plugInController didCreateBrowserContextController:(WKWebProcessPlugInBrowserContextController *)browserContextController;
 - (void)webProcessPlugIn:(WKWebProcessPlugInController *)plugInController willDestroyBrowserContextController:(WKWebProcessPlugInBrowserContextController *)browserContextController;
-- (NSArray *)additionalClassesForParameterCoder;
 @end
 
 WK_CLASS_AVAILABLE(macos(10.10), ios(8.0))
index 8a463f2..1ffe2c3 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2010-2019 Apple Inc. All rights reserved.
+ * Copyright (C) 2010-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
@@ -167,10 +167,6 @@ public:
 private:
     explicit InjectedBundle(const WebProcessCreationParameters&);
 
-#if PLATFORM(COCOA)
-    bool decodeBundleParameters(API::Data*);
-#endif
-
     String m_path;
     PlatformBundle m_platformBundle; // This is leaked right now, since we never unload the bundle/module.
 
index 806a361..52f825d 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2010-2019 Apple Inc. All rights reserved.
+ * Copyright (C) 2010-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
@@ -73,29 +73,6 @@ static NSEventModifierFlags currentModifierFlags(id self, SEL _cmd)
 }
 #endif
 
-bool InjectedBundle::decodeBundleParameters(API::Data* bundleParameterDataPtr)
-{
-    if (!bundleParameterDataPtr)
-        return true;
-
-    auto bundleParameterData = adoptNS([[NSData alloc] initWithBytesNoCopy:const_cast<void*>(static_cast<const void*>(bundleParameterDataPtr->bytes())) length:bundleParameterDataPtr->size() freeWhenDone:NO]);
-    
-    auto unarchiver = secureUnarchiverFromData(bundleParameterData.get());
-    
-    NSDictionary *dictionary = nil;
-    @try {
-        dictionary = [unarchiver.get() decodeObjectOfClasses:classesForCoder() forKey:@"parameters"];
-        ASSERT([dictionary isKindOfClass:[NSDictionary class]]);
-    } @catch (NSException *exception) {
-        LOG_ERROR("Failed to decode bundle parameters: %@", exception);
-        return false;
-    }
-    
-    ASSERT(!m_bundleParameters || m_bundleParameters.get());
-    m_bundleParameters = adoptNS([[WKWebProcessBundleParameters alloc] initWithDictionary:dictionary]);
-    return true;
-}
-
 bool InjectedBundle::initialize(const WebProcessCreationParameters& parameters, API::Object* initializationUserData)
 {
     if (m_sandboxExtension) {
@@ -143,8 +120,23 @@ bool InjectedBundle::initialize(const WebProcessCreationParameters& parameters,
         }
     }
 
-    bool successfullyDecoded = decodeBundleParameters(parameters.bundleParameterData.get());
+    if (parameters.bundleParameterData) {
+        auto bundleParameterData = adoptNS([[NSData alloc] initWithBytesNoCopy:const_cast<void*>(static_cast<const void*>(parameters.bundleParameterData->bytes())) length:parameters.bundleParameterData->size() freeWhenDone:NO]);
+
+        auto unarchiver = secureUnarchiverFromData(bundleParameterData.get());
+
+        NSDictionary *dictionary = nil;
+        @try {
+            dictionary = [unarchiver.get() decodeObjectOfClass:[NSObject class] forKey:@"parameters"];
+            ASSERT([dictionary isKindOfClass:[NSDictionary class]]);
+        } @catch (NSException *exception) {
+            LOG_ERROR("Failed to decode bundle parameters: %@", exception);
+        }
 
+        ASSERT(!m_bundleParameters);
+        m_bundleParameters = adoptNS([[WKWebProcessBundleParameters alloc] initWithDictionary:dictionary]);
+    }
+    
 #if ENABLE(WEBPROCESS_WINDOWSERVER_BLOCKING)
     // Swizzle [NSEvent modiferFlags], since it always returns 0 when the WindowServer is blocked.
     Method method = class_getClassMethod([NSEvent class], @selector(modifierFlags));
@@ -157,8 +149,6 @@ bool InjectedBundle::initialize(const WebProcessCreationParameters& parameters,
     // First check to see if the bundle has a WKBundleInitialize function.
     if (initializeFunction) {
         initializeFunction(toAPI(this), toAPI(initializationUserData));
-        if (!successfullyDecoded)
-            decodeBundleParameters(parameters.bundleParameterData.get());
         return true;
     }
 
@@ -183,11 +173,6 @@ bool InjectedBundle::initialize(const WebProcessCreationParameters& parameters,
     WKWebProcessPlugInController* plugInController = WebKit::wrapper(*this);
     [plugInController _setPrincipalClassInstance:instance];
 
-    if ([instance respondsToSelector:@selector(additionalClassesForParameterCoder)]) {
-        [plugInController extendClassesForParameterCoder:[instance additionalClassesForParameterCoder]];
-        decodeBundleParameters(parameters.bundleParameterData.get());
-    }
-
     if ([instance respondsToSelector:@selector(webProcessPlugIn:initializeWithObject:)]) {
         RetainPtr<id> objCInitializationUserData;
         if (initializationUserData && initializationUserData->type() == API::Object::Type::ObjCObjectGraph)
@@ -270,7 +255,7 @@ void InjectedBundle::setBundleParameters(const IPC::DataReference& value)
 
     NSDictionary *parameters = nil;
     @try {
-        parameters = [unarchiver decodeObjectOfClasses:classesForCoder() forKey:@"parameters"];
+        parameters = [unarchiver decodeObjectOfClass:[NSDictionary class] forKey:@"parameters"];
     } @catch (NSException *exception) {
         LOG_ERROR("Failed to decode bundle parameter: %@", exception);
     }
@@ -278,8 +263,6 @@ void InjectedBundle::setBundleParameters(const IPC::DataReference& value)
     if (!parameters)
         return;
 
-    RELEASE_ASSERT_WITH_SECURITY_IMPLICATION([parameters isKindOfClass:[NSDictionary class]]);
-
     if (!m_bundleParameters) {
         m_bundleParameters = adoptNS([[WKWebProcessBundleParameters alloc] initWithDictionary:parameters]);
         return;
index 7507779..5f66a79 100644 (file)
@@ -1,3 +1,16 @@
+2019-04-22  Ryan Haddad  <ryanhaddad@apple.com>
+
+        Unreviewed, rolling out r244437.
+
+        Still breaks internal tests.
+
+        Reverted changeset:
+
+        "InjectedBundle parameters often need initialization function
+        called before unarchiving"
+        https://bugs.webkit.org/show_bug.cgi?id=189709
+        https://trac.webkit.org/changeset/244437
+
 2019-04-22  Aakash Jain  <aakash_jain@apple.com>
 
         [ews-build] Use singular verb in failure description in case of single api test failure
index 363ad1f..40746ab 100644 (file)
     RetainPtr<id <WKWebProcessPlugIn>> _testPlugIn;
 }
 
-- (NSArray *)additionalClassesForParameterCoder
-{
-    return @[@"MockContentFilterEnabler"];
-}
-
 - (void)webProcessPlugIn:(WKWebProcessPlugInController *)plugInController initializeWithObject:(id)initializationObject
 {
     NSString *testPlugInClassName = [plugInController.parameters valueForKey:TestWebKitAPI::Util::TestPlugInClassNameParameter];