OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "sandbox/mac/bootstrap_sandbox.h" | 5 #include "sandbox/mac/bootstrap_sandbox.h" |
6 | 6 |
7 #include <CoreFoundation/CoreFoundation.h> | 7 #include <CoreFoundation/CoreFoundation.h> |
8 #import <Foundation/Foundation.h> | 8 #import <Foundation/Foundation.h> |
9 #include <mach/mach.h> | 9 #include <mach/mach.h> |
10 #include <servers/bootstrap.h> | 10 #include <servers/bootstrap.h> |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
57 return receivedCount_; | 57 return receivedCount_; |
58 } | 58 } |
59 | 59 |
60 - (NSString*)object { | 60 - (NSString*)object { |
61 return object_.get(); | 61 return object_.get(); |
62 } | 62 } |
63 | 63 |
64 - (void)waitForNotification { | 64 - (void)waitForNotification { |
65 object_.reset(); | 65 object_.reset(); |
66 CFRunLoopRunInMode(kCFRunLoopDefaultMode, | 66 CFRunLoopRunInMode(kCFRunLoopDefaultMode, |
67 TestTimeouts::action_timeout().InSeconds(), false); | 67 TestTimeouts::action_timeout().InSeconds(), false); |
Robert Sesek
2014/08/25 14:19:37
So is this not the right thing to use now? This is
| |
68 } | 68 } |
69 | 69 |
70 - (void)observeNotification:(NSNotification*)notification { | 70 - (void)observeNotification:(NSNotification*)notification { |
71 ++receivedCount_; | 71 ++receivedCount_; |
72 object_.reset([[notification object] copy]); | 72 object_.reset([[notification object] copy]); |
73 CFRunLoopStop(CFRunLoopGetCurrent()); | 73 CFRunLoopStop(CFRunLoopGetCurrent()); |
74 } | 74 } |
75 @end | 75 @end |
76 | 76 |
77 //////////////////////////////////////////////////////////////////////////////// | 77 //////////////////////////////////////////////////////////////////////////////// |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
127 EXPECT_TRUE(base::WaitForExitCode(pid, &code)); | 127 EXPECT_TRUE(base::WaitForExitCode(pid, &code)); |
128 EXPECT_EQ(0, code); | 128 EXPECT_EQ(0, code); |
129 | 129 |
130 [observer waitForNotification]; | 130 [observer waitForNotification]; |
131 EXPECT_EQ(1, [observer receivedCount]); | 131 EXPECT_EQ(1, [observer receivedCount]); |
132 EXPECT_EQ(pid, [[observer object] intValue]); | 132 EXPECT_EQ(pid, [[observer object] intValue]); |
133 } | 133 } |
134 | 134 |
135 // Run the test with the sandbox enabled without notifications on the policy | 135 // Run the test with the sandbox enabled without notifications on the policy |
136 // whitelist. | 136 // whitelist. |
137 TEST_F(BootstrapSandboxTest, DistributedNotifications_SandboxDeny) { | 137 // Disabled, http://crbug.com/407066 . |
138 TEST_F(BootstrapSandboxTest, DISABLED_DistributedNotifications_SandboxDeny) { | |
138 base::scoped_nsobject<DistributedNotificationObserver> observer( | 139 base::scoped_nsobject<DistributedNotificationObserver> observer( |
139 [[DistributedNotificationObserver alloc] init]); | 140 [[DistributedNotificationObserver alloc] init]); |
140 | 141 |
141 sandbox_->RegisterSandboxPolicy(1, BaselinePolicy()); | 142 sandbox_->RegisterSandboxPolicy(1, BaselinePolicy()); |
142 RunChildWithPolicy(1, kNotificationTestMain, NULL); | 143 RunChildWithPolicy(1, kNotificationTestMain, NULL); |
143 | 144 |
144 [observer waitForNotification]; | 145 [observer waitForNotification]; |
145 EXPECT_EQ(0, [observer receivedCount]); | 146 EXPECT_EQ(0, [observer receivedCount]); |
146 EXPECT_EQ(nil, [observer object]); | 147 EXPECT_EQ(nil, [observer object]); |
147 } | 148 } |
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
510 kr = mach_msg_receive(&rcv_msg.header); | 511 kr = mach_msg_receive(&rcv_msg.header); |
511 MACH_CHECK(kr == KERN_SUCCESS, kr) << "mach_msg_receive"; | 512 MACH_CHECK(kr == KERN_SUCCESS, kr) << "mach_msg_receive"; |
512 | 513 |
513 // Try to message the sandbox. | 514 // Try to message the sandbox. |
514 bootstrap_look_up(bootstrap_port, "test", &port); | 515 bootstrap_look_up(bootstrap_port, "test", &port); |
515 | 516 |
516 return 0; | 517 return 0; |
517 } | 518 } |
518 | 519 |
519 } // namespace sandbox | 520 } // namespace sandbox |
OLD | NEW |