diff --git a/modules/angular2/src/core/testability/testability.ts b/modules/angular2/src/core/testability/testability.ts index f8cb22bf47b6d..d15690d15a477 100644 --- a/modules/angular2/src/core/testability/testability.ts +++ b/modules/angular2/src/core/testability/testability.ts @@ -118,6 +118,8 @@ export class TestabilityRegistry { getAllTestabilities(): Testability[] { return MapWrapper.values(this._applications); } + getAllRootElements(): any[] { return MapWrapper.keys(this._applications); } + findTestabilityInTree(elem: Node, findInAncestors: boolean = true): Testability { return _testabilityGetter.findTestabilityInTree(this, elem, findInAncestors); } diff --git a/modules/angular2/src/facade/lang.ts b/modules/angular2/src/facade/lang.ts index b1dd0568303dd..eee138d4fce66 100644 --- a/modules/angular2/src/facade/lang.ts +++ b/modules/angular2/src/facade/lang.ts @@ -24,6 +24,7 @@ export interface BrowserNodeGlobal { Zone: ZoneLikeConstructor; getAngularTestability: Function; getAllAngularTestabilities: Function; + getAllAngularRootElements: Function; frameworkStabilizers: Array; setTimeout: Function; clearTimeout: Function; diff --git a/modules/angular2/src/platform/browser/testability.ts b/modules/angular2/src/platform/browser/testability.ts index 5d1a637779b69..7b45856a20754 100644 --- a/modules/angular2/src/platform/browser/testability.ts +++ b/modules/angular2/src/platform/browser/testability.ts @@ -49,6 +49,8 @@ export class BrowserGetTestability implements GetTestability { return testabilities.map((testability) => { return new PublicTestability(testability); }); }; + global.getAllAngularRootElements = () => registry.getAllRootElements(); + var whenAllStable = (callback) => { var testabilities = global.getAllAngularTestabilities(); var count = testabilities.length; diff --git a/modules/angular2/src/platform/dom/debug/ng_probe.ts b/modules/angular2/src/platform/dom/debug/ng_probe.ts index 61bc6b9e71aff..6087a4d06c456 100644 --- a/modules/angular2/src/platform/dom/debug/ng_probe.ts +++ b/modules/angular2/src/platform/dom/debug/ng_probe.ts @@ -3,11 +3,13 @@ import {Injectable, provide, Provider} from 'angular2/src/core/di'; import {DOM} from 'angular2/src/platform/dom/dom_adapter'; import {DebugNode, getDebugNode} from 'angular2/src/core/debug/debug_node'; import {DomRootRenderer} from 'angular2/src/platform/dom/dom_renderer'; -import {RootRenderer} from 'angular2/core'; +import {RootRenderer, NgZone, ApplicationRef} from 'angular2/core'; import {DebugDomRootRenderer} from 'angular2/src/core/debug/debug_renderer'; +const CORE_TOKENS = CONST_EXPR({'ApplicationRef': ApplicationRef, 'NgZone': NgZone}); const INSPECT_GLOBAL_NAME = 'ng.probe'; +const CORE_TOKENS_GLOBAL_NAME = 'ng.coreTokens'; /** * Returns a {@link DebugElement} for the given native DOM element, or @@ -27,6 +29,7 @@ function _createConditionalRootRenderer(rootRenderer) { function _createRootRenderer(rootRenderer) { DOM.setGlobalVar(INSPECT_GLOBAL_NAME, inspectNativeElement); + DOM.setGlobalVar(CORE_TOKENS_GLOBAL_NAME, CORE_TOKENS); return new DebugDomRootRenderer(rootRenderer); } diff --git a/modules/angular2/test/public_api_spec.ts b/modules/angular2/test/public_api_spec.ts index 61051abdeb1db..3f347d8d374db 100644 --- a/modules/angular2/test/public_api_spec.ts +++ b/modules/angular2/test/public_api_spec.ts @@ -1286,6 +1286,7 @@ var NG_CORE = [ 'TestabilityRegistry', 'TestabilityRegistry.findTestabilityInTree()', 'TestabilityRegistry.getAllTestabilities()', + 'TestabilityRegistry.getAllRootElements()', 'TestabilityRegistry.getTestability()', 'TestabilityRegistry.registerApplication()', 'GetTestability:dart', diff --git a/tools/public_api_guard/public_api_spec.ts b/tools/public_api_guard/public_api_spec.ts index fbd6a20ac354a..bbc1a9524e529 100644 --- a/tools/public_api_guard/public_api_spec.ts +++ b/tools/public_api_guard/public_api_spec.ts @@ -439,6 +439,7 @@ const CORE = [ 'TestabilityRegistry.constructor()', 'TestabilityRegistry.findTestabilityInTree(elem:Node, findInAncestors:boolean):Testability', 'TestabilityRegistry.getAllTestabilities():Testability[]', + 'TestabilityRegistry.getAllRootElements():any[]', 'TestabilityRegistry.getTestability(elem:any):Testability', 'TestabilityRegistry.registerApplication(token:any, testability:Testability):any', 'TrackByFn',