IN_PROC_BROWSER_TEST_F ( ExtensionPreferenceApiTest , OnChangeSplit ) {
 extensions : : ResultCatcher catcher ;
 catcher . RestrictToBrowserContext ( profile_ ) ;
 extensions : : ResultCatcher catcher_incognito ;
 catcher_incognito . RestrictToBrowserContext ( profile_ -> GetOffTheRecordProfile ( ) ) ;
 OpenURLOffTheRecord ( profile_ , GURL ( "chrome:/ewtab/" ) ) ;
 ExtensionTestMessageListener listener1 ( "changeDefault regular ready" , true ) ;
 ExtensionTestMessageListener listener_incognito1 ( "changeDefault incognito ready" , true ) ;
 ExtensionTestMessageListener listener2 ( "changeIncognitoOnly regular ready" , true ) ;
 ExtensionTestMessageListener listener_incognito2 ( "changeIncognitoOnly incognito ready" , true ) ;
 ExtensionTestMessageListener listener3 ( "changeIncognitoOnly regular listening" , true ) ;
 ExtensionTestMessageListener listener_incognito3 ( "changeIncognitoOnly incognito pref set" , false ) ;
 ExtensionTestMessageListener listener4 ( "changeDefaultOnly regular ready" , true ) ;
 ExtensionTestMessageListener listener_incognito4 ( "changeDefaultOnly incognito ready" , true ) ;
 ExtensionTestMessageListener listener5 ( "changeDefaultOnly regular pref set" , false ) ;
 ExtensionTestMessageListener listener_incognito5 ( "changeDefaultOnly incognito listening" , true ) ;
 ExtensionTestMessageListener listener6 ( "changeIncognitoOnlyBack regular ready" , true ) ;
 ExtensionTestMessageListener listener_incognito6 ( "changeIncognitoOnlyBack incognito ready" , true ) ;
 ExtensionTestMessageListener listener7 ( "changeIncognitoOnlyBack regular listening" , true ) ;
 ExtensionTestMessageListener listener_incognito7 ( "changeIncognitoOnlyBack incognito pref set" , false ) ;
 ExtensionTestMessageListener listener8 ( "clearIncognito regular ready" , true ) ;
 ExtensionTestMessageListener listener_incognito8 ( "clearIncognito incognito ready" , true ) ;
 ExtensionTestMessageListener listener9 ( "clearIncognito regular listening" , true ) ;
 ExtensionTestMessageListener listener_incognito9 ( "clearIncognito incognito pref cleared" , false ) ;
 ExtensionTestMessageListener listener10 ( "clearDefault regular ready" , true ) ;
 ExtensionTestMessageListener listener_incognito10 ( "clearDefault incognito ready" , true ) ;
 base : : FilePath extension_data_dir = test_data_dir_ . AppendASCII ( "preference" ) . AppendASCII ( "onchange_split" ) ;
 ASSERT_TRUE ( LoadExtensionIncognito ( extension_data_dir ) ) ;
 EXPECT_TRUE ( listener1 . WaitUntilSatisfied ( ) ) ;
 EXPECT_TRUE ( listener_incognito1 . WaitUntilSatisfied ( ) ) ;
 listener1 . Reply ( "ok" ) ;
 listener_incognito1 . Reply ( "ok" ) ;
 EXPECT_TRUE ( listener2 . WaitUntilSatisfied ( ) ) ;
 EXPECT_TRUE ( listener_incognito2 . WaitUntilSatisfied ( ) ) ;
 EXPECT_TRUE ( listener3 . WaitUntilSatisfied ( ) ) ;
 listener2 . Reply ( "ok" ) ;
 listener_incognito2 . Reply ( "ok" ) ;
 EXPECT_TRUE ( listener_incognito3 . WaitUntilSatisfied ( ) ) ;
 listener3 . Reply ( "ok" ) ;
 EXPECT_TRUE ( listener4 . WaitUntilSatisfied ( ) ) ;
 EXPECT_TRUE ( listener_incognito4 . WaitUntilSatisfied ( ) ) ;
 EXPECT_TRUE ( listener_incognito5 . WaitUntilSatisfied ( ) ) ;
 listener4 . Reply ( "ok" ) ;
 listener_incognito4 . Reply ( "ok" ) ;
 EXPECT_TRUE ( listener5 . WaitUntilSatisfied ( ) ) ;
 listener_incognito5 . Reply ( "ok" ) ;
 EXPECT_TRUE ( listener6 . WaitUntilSatisfied ( ) ) ;
 EXPECT_TRUE ( listener_incognito6 . WaitUntilSatisfied ( ) ) ;
 EXPECT_TRUE ( listener7 . WaitUntilSatisfied ( ) ) ;
 listener6 . Reply ( "ok" ) ;
 listener_incognito6 . Reply ( "ok" ) ;
 EXPECT_TRUE ( listener_incognito7 . WaitUntilSatisfied ( ) ) ;
 listener7 . Reply ( "ok" ) ;
 EXPECT_TRUE ( listener8 . WaitUntilSatisfied ( ) ) ;
 EXPECT_TRUE ( listener_incognito8 . WaitUntilSatisfied ( ) ) ;
 EXPECT_TRUE ( listener9 . WaitUntilSatisfied ( ) ) ;
 listener8 . Reply ( "ok" ) ;
 listener_incognito8 . Reply ( "ok" ) ;
 EXPECT_TRUE ( listener_incognito9 . WaitUntilSatisfied ( ) ) ;
 listener9 . Reply ( "ok" ) ;
 EXPECT_TRUE ( listener10 . WaitUntilSatisfied ( ) ) ;
 EXPECT_TRUE ( listener_incognito10 . WaitUntilSatisfied ( ) ) ;
 listener10 . Reply ( "ok" ) ;
 listener_incognito10 . Reply ( "ok" ) ;
 EXPECT_TRUE ( catcher . GetNextResult ( ) ) << catcher . message ( ) ;
 EXPECT_TRUE ( catcher_incognito . GetNextResult ( ) ) << catcher_incognito . message ( ) ;
 }
IN_PROC_BROWSER_TEST_F ( ExtensionPreferenceApiTest , OnChangeSplit ) {
 extensions : : ResultCatcher catcher ;
 catcher . RestrictToBrowserContext ( profile_ ) ;
 extensions : : ResultCatcher catcher_incognito ;
 catcher_incognito . RestrictToBrowserContext ( profile_ -> GetOffTheRecordProfile ( ) ) ;
 OpenURLOffTheRecord ( profile_ , GURL ( "chrome:/ewtab/" ) ) ;
 ExtensionTestMessageListener listener1 ( "changeDefault regular ready" , true ) ;
 ExtensionTestMessageListener listener_incognito1 ( "changeDefault incognito ready" , true ) ;
 ExtensionTestMessageListener listener2 ( "changeIncognitoOnly regular ready" , true ) ;
 ExtensionTestMessageListener listener_incognito2 ( "changeIncognitoOnly incognito ready" , true ) ;
 ExtensionTestMessageListener listener3 ( "changeIncognitoOnly regular listening" , true ) ;
 ExtensionTestMessageListener listener_incognito3 ( "changeIncognitoOnly incognito pref set" , false ) ;
 ExtensionTestMessageListener listener4 ( "changeDefaultOnly regular ready" , true ) ;
 ExtensionTestMessageListener listener_incognito4 ( "changeDefaultOnly incognito ready" , true ) ;
 ExtensionTestMessageListener listener5 ( "changeDefaultOnly regular pref set" , false ) ;
 ExtensionTestMessageListener listener_incognito5 ( "changeDefaultOnly incognito listening" , true ) ;
 ExtensionTestMessageListener listener6 ( "changeIncognitoOnlyBack regular ready" , true ) ;
 ExtensionTestMessageListener listener_incognito6 ( "changeIncognitoOnlyBack incognito ready" , true ) ;
 ExtensionTestMessageListener listener7 ( "changeIncognitoOnlyBack regular listening" , true ) ;
 ExtensionTestMessageListener listener_incognito7 ( "changeIncognitoOnlyBack incognito pref set" , false ) ;
 ExtensionTestMessageListener listener8 ( "clearIncognito regular ready" , true ) ;
 ExtensionTestMessageListener listener_incognito8 ( "clearIncognito incognito ready" , true ) ;
 ExtensionTestMessageListener listener9 ( "clearIncognito regular listening" , true ) ;
 ExtensionTestMessageListener listener_incognito9 ( "clearIncognito incognito pref cleared" , false ) ;
 ExtensionTestMessageListener listener10 ( "clearDefault regular ready" , true ) ;
 ExtensionTestMessageListener listener_incognito10 ( "clearDefault incognito ready" , true ) ;
 base : : FilePath extension_data_dir = test_data_dir_ . AppendASCII ( "preference" ) . AppendASCII ( "onchange_split" ) ;
 ASSERT_TRUE ( LoadExtensionIncognito ( extension_data_dir ) ) ;
 EXPECT_TRUE ( listener1 . WaitUntilSatisfied ( ) ) ;
 EXPECT_TRUE ( listener_incognito1 . WaitUntilSatisfied ( ) ) ;
 listener1 . Reply ( "ok" ) ;
 listener_incognito1 . Reply ( "ok" ) ;
 EXPECT_TRUE ( listener2 . WaitUntilSatisfied ( ) ) ;
 EXPECT_TRUE ( listener_incognito2 . WaitUntilSatisfied ( ) ) ;
 EXPECT_TRUE ( listener3 . WaitUntilSatisfied ( ) ) ;
 listener2 . Reply ( "ok" ) ;
 listener_incognito2 . Reply ( "ok" ) ;
 EXPECT_TRUE ( listener_incognito3 . WaitUntilSatisfied ( ) ) ;
 listener3 . Reply ( "ok" ) ;
 EXPECT_TRUE ( listener4 . WaitUntilSatisfied ( ) ) ;
 EXPECT_TRUE ( listener_incognito4 . WaitUntilSatisfied ( ) ) ;
 EXPECT_TRUE ( listener_incognito5 . WaitUntilSatisfied ( ) ) ;
 listener4 . Reply ( "ok" ) ;
 listener_incognito4 . Reply ( "ok" ) ;
 EXPECT_TRUE ( listener5 . WaitUntilSatisfied ( ) ) ;
 listener_incognito5 . Reply ( "ok" ) ;
 EXPECT_TRUE ( listener6 . WaitUntilSatisfied ( ) ) ;
 EXPECT_TRUE ( listener_incognito6 . WaitUntilSatisfied ( ) ) ;
 EXPECT_TRUE ( listener7 . WaitUntilSatisfied ( ) ) ;
 listener6 . Reply ( "ok" ) ;
 listener_incognito6 . Reply ( "ok" ) ;
 EXPECT_TRUE ( listener_incognito7 . WaitUntilSatisfied ( ) ) ;
 listener7 . Reply ( "ok" ) ;
 EXPECT_TRUE ( listener8 . WaitUntilSatisfied ( ) ) ;
 EXPECT_TRUE ( listener_incognito8 . WaitUntilSatisfied ( ) ) ;
 EXPECT_TRUE ( listener9 . WaitUntilSatisfied ( ) ) ;
 listener8 . Reply ( "ok" ) ;
 listener_incognito8 . Reply ( "ok" ) ;
 EXPECT_TRUE ( listener_incognito9 . WaitUntilSatisfied ( ) ) ;
 listener9 . Reply ( "ok" ) ;
 EXPECT_TRUE ( listener10 . WaitUntilSatisfied ( ) ) ;
 EXPECT_TRUE ( listener_incognito10 . WaitUntilSatisfied ( ) ) ;
 listener10 . Reply ( "ok" ) ;
 listener_incognito10 . Reply ( "ok" ) ;
 EXPECT_TRUE ( catcher . GetNextResult ( ) ) << catcher . message ( ) ;
 EXPECT_TRUE ( catcher_incognito . GetNextResult ( ) ) << catcher_incognito . message ( ) ;
 }