Check if test runner is of right type before accessing its internals

Summary: I previously added this check to make the test complete waits until all teardown completed but if you're running tests with any other executor than the JSC one, this would crash.

@​public

Reviewed By: @jspahrsummers

Differential Revision: D2493967
This commit is contained in:
Pieter De Baets 2015-10-01 04:19:46 -07:00 committed by facebook-github-bot-7
parent 7f9cf97767
commit f3a6466fcd
1 changed files with 5 additions and 1 deletions

View File

@ -15,6 +15,7 @@
#import "RCTRootView.h" #import "RCTRootView.h"
#import "RCTTestModule.h" #import "RCTTestModule.h"
#import "RCTUtils.h" #import "RCTUtils.h"
#import "RCTContextExecutor.h"
static const NSTimeInterval kTestTimeoutSeconds = 60; static const NSTimeInterval kTestTimeoutSeconds = 60;
static const NSTimeInterval kTestTeardownTimeoutSeconds = 30; static const NSTimeInterval kTestTeardownTimeoutSeconds = 30;
@ -114,7 +115,10 @@ RCT_NOT_IMPLEMENTED(- (instancetype)init)
// Take a weak reference to the JS context, so we track its deallocation later // Take a weak reference to the JS context, so we track its deallocation later
// (we can only do this now, since it's been lazily initialized) // (we can only do this now, since it's been lazily initialized)
weakJSContext = [[[bridge valueForKey:@"batchedBridge"] valueForKey:@"javaScriptExecutor"] valueForKey:@"context"]; id jsExecutor = [bridge valueForKeyPath:@"batchedBridge.javaScriptExecutor"];
if ([jsExecutor isKindOfClass:[RCTContextExecutor class]]) {
weakJSContext = [jsExecutor valueForKey:@"context"];
}
[rootView removeFromSuperview]; [rootView removeFromSuperview];
RCTSetLogFunction(RCTDefaultLogFunction); RCTSetLogFunction(RCTDefaultLogFunction);