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:
parent
c9a3df970b
commit
b5e6319fa9
|
@ -118,6 +118,8 @@ export class TestabilityRegistry {
|
||||||
|
|
||||||
getAllTestabilities(): Testability[] { return MapWrapper.values(this._applications); }
|
getAllTestabilities(): Testability[] { return MapWrapper.values(this._applications); }
|
||||||
|
|
||||||
|
getAllRootElements(): any[] { return MapWrapper.keys(this._applications); }
|
||||||
|
|
||||||
findTestabilityInTree(elem: Node, findInAncestors: boolean = true): Testability {
|
findTestabilityInTree(elem: Node, findInAncestors: boolean = true): Testability {
|
||||||
return _testabilityGetter.findTestabilityInTree(this, elem, findInAncestors);
|
return _testabilityGetter.findTestabilityInTree(this, elem, findInAncestors);
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,7 @@ export interface BrowserNodeGlobal {
|
||||||
Zone: ZoneLikeConstructor;
|
Zone: ZoneLikeConstructor;
|
||||||
getAngularTestability: Function;
|
getAngularTestability: Function;
|
||||||
getAllAngularTestabilities: Function;
|
getAllAngularTestabilities: Function;
|
||||||
|
getAllAngularRootElements: Function;
|
||||||
frameworkStabilizers: Array<Function>;
|
frameworkStabilizers: Array<Function>;
|
||||||
setTimeout: Function;
|
setTimeout: Function;
|
||||||
clearTimeout: Function;
|
clearTimeout: Function;
|
||||||
|
|
|
@ -49,6 +49,8 @@ export class BrowserGetTestability implements GetTestability {
|
||||||
return testabilities.map((testability) => { return new PublicTestability(testability); });
|
return testabilities.map((testability) => { return new PublicTestability(testability); });
|
||||||
};
|
};
|
||||||
|
|
||||||
|
global.getAllAngularRootElements = () => registry.getAllRootElements();
|
||||||
|
|
||||||
var whenAllStable = (callback) => {
|
var whenAllStable = (callback) => {
|
||||||
var testabilities = global.getAllAngularTestabilities();
|
var testabilities = global.getAllAngularTestabilities();
|
||||||
var count = testabilities.length;
|
var count = testabilities.length;
|
||||||
|
|
|
@ -3,11 +3,13 @@ import {Injectable, provide, Provider} from 'angular2/src/core/di';
|
||||||
import {DOM} from 'angular2/src/platform/dom/dom_adapter';
|
import {DOM} from 'angular2/src/platform/dom/dom_adapter';
|
||||||
import {DebugNode, getDebugNode} from 'angular2/src/core/debug/debug_node';
|
import {DebugNode, getDebugNode} from 'angular2/src/core/debug/debug_node';
|
||||||
import {DomRootRenderer} from 'angular2/src/platform/dom/dom_renderer';
|
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';
|
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 INSPECT_GLOBAL_NAME = 'ng.probe';
|
||||||
|
const CORE_TOKENS_GLOBAL_NAME = 'ng.coreTokens';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a {@link DebugElement} for the given native DOM element, or
|
* Returns a {@link DebugElement} for the given native DOM element, or
|
||||||
|
@ -27,6 +29,7 @@ function _createConditionalRootRenderer(rootRenderer) {
|
||||||
|
|
||||||
function _createRootRenderer(rootRenderer) {
|
function _createRootRenderer(rootRenderer) {
|
||||||
DOM.setGlobalVar(INSPECT_GLOBAL_NAME, inspectNativeElement);
|
DOM.setGlobalVar(INSPECT_GLOBAL_NAME, inspectNativeElement);
|
||||||
|
DOM.setGlobalVar(CORE_TOKENS_GLOBAL_NAME, CORE_TOKENS);
|
||||||
return new DebugDomRootRenderer(rootRenderer);
|
return new DebugDomRootRenderer(rootRenderer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1308,6 +1308,7 @@ var NG_CORE = [
|
||||||
'TestabilityRegistry',
|
'TestabilityRegistry',
|
||||||
'TestabilityRegistry.findTestabilityInTree()',
|
'TestabilityRegistry.findTestabilityInTree()',
|
||||||
'TestabilityRegistry.getAllTestabilities()',
|
'TestabilityRegistry.getAllTestabilities()',
|
||||||
|
'TestabilityRegistry.getAllRootElements()',
|
||||||
'TestabilityRegistry.getTestability()',
|
'TestabilityRegistry.getTestability()',
|
||||||
'TestabilityRegistry.registerApplication()',
|
'TestabilityRegistry.registerApplication()',
|
||||||
'GetTestability:dart',
|
'GetTestability:dart',
|
||||||
|
|
|
@ -440,6 +440,7 @@ const CORE = [
|
||||||
'TestabilityRegistry.constructor()',
|
'TestabilityRegistry.constructor()',
|
||||||
'TestabilityRegistry.findTestabilityInTree(elem:Node, findInAncestors:boolean):Testability',
|
'TestabilityRegistry.findTestabilityInTree(elem:Node, findInAncestors:boolean):Testability',
|
||||||
'TestabilityRegistry.getAllTestabilities():Testability[]',
|
'TestabilityRegistry.getAllTestabilities():Testability[]',
|
||||||
|
'TestabilityRegistry.getAllRootElements():any[]',
|
||||||
'TestabilityRegistry.getTestability(elem:any):Testability',
|
'TestabilityRegistry.getTestability(elem:any):Testability',
|
||||||
'TestabilityRegistry.registerApplication(token:any, testability:Testability):any',
|
'TestabilityRegistry.registerApplication(token:any, testability:Testability):any',
|
||||||
'TrackByFn',
|
'TrackByFn',
|
||||||
|
|
Loading…
Reference in New Issue