feat(core): add more debug APIs to inspect the application form a browser

Adds `window.getAllAngularRootElements()`
Adds `ng.coreTokens.ApplicationRef`
Adds `ng.coreTokens.Ngzone`

Closes #7045
Closes #7161
This commit is contained in:
Tobias Bosch 2016-02-18 13:51:20 -08:00
parent c9a3df970b
commit b5e6319fa9
6 changed files with 11 additions and 1 deletions

View File

@ -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);
}

View File

@ -24,6 +24,7 @@ export interface BrowserNodeGlobal {
Zone: ZoneLikeConstructor;
getAngularTestability: Function;
getAllAngularTestabilities: Function;
getAllAngularRootElements: Function;
frameworkStabilizers: Array<Function>;
setTimeout: Function;
clearTimeout: Function;

View File

@ -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;

View File

@ -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);
}

View File

@ -1308,6 +1308,7 @@ var NG_CORE = [
'TestabilityRegistry',
'TestabilityRegistry.findTestabilityInTree()',
'TestabilityRegistry.getAllTestabilities()',
'TestabilityRegistry.getAllRootElements()',
'TestabilityRegistry.getTestability()',
'TestabilityRegistry.registerApplication()',
'GetTestability:dart',

View File

@ -440,6 +440,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',