@@ -1639,22 +1639,19 @@ describe('angular', function() {
1639
1639
1640
1640
1641
1641
describe ( 'deferred bootstrap' , function ( ) {
1642
- var originalName = window . name ,
1643
- element ;
1642
+ var element ;
1644
1643
1645
1644
beforeEach ( function ( ) {
1646
- window . name = '' ;
1647
1645
element = jqLite ( '<div>{{1+2}}</div>' ) ;
1648
1646
} ) ;
1649
1647
1650
1648
afterEach ( function ( ) {
1651
1649
dealoc ( element ) ;
1652
- window . name = originalName ;
1653
1650
} ) ;
1654
1651
1655
1652
it ( 'should provide injector for deferred bootstrap' , function ( ) {
1656
1653
var injector ;
1657
- window . name = 'NG_DEFER_BOOTSTRAP!' ;
1654
+ document . cookie = 'NG_DEFER_BOOTSTRAP!=true ' ;
1658
1655
1659
1656
injector = angular . bootstrap ( element ) ;
1660
1657
expect ( injector ) . toBeUndefined ( ) ;
@@ -1665,7 +1662,7 @@ describe('angular', function() {
1665
1662
1666
1663
it ( 'should resume deferred bootstrap, if defined' , function ( ) {
1667
1664
var injector ;
1668
- window . name = 'NG_DEFER_BOOTSTRAP!' ;
1665
+ document . cookie = 'NG_DEFER_BOOTSTRAP!=true ' ;
1669
1666
1670
1667
angular . resumeDeferredBootstrap = noop ;
1671
1668
var spy = spyOn ( angular , "resumeDeferredBootstrap" ) ;
@@ -1674,21 +1671,21 @@ describe('angular', function() {
1674
1671
} ) ;
1675
1672
1676
1673
it ( 'should wait for extra modules' , function ( ) {
1677
- window . name = 'NG_DEFER_BOOTSTRAP!' ;
1674
+ document . cookie = 'NG_DEFER_BOOTSTRAP!=true ' ;
1678
1675
angular . bootstrap ( element ) ;
1679
1676
1680
1677
expect ( element . html ( ) ) . toBe ( '{{1+2}}' ) ;
1681
1678
1682
1679
angular . resumeBootstrap ( ) ;
1683
1680
1684
1681
expect ( element . html ( ) ) . toBe ( '3' ) ;
1685
- expect ( window . name ) . toEqual ( '' ) ;
1682
+ expect ( / \b N G _ D E F E R _ B O O T S T R A P ! = t r u e \b / . test ( document . cookie ) ) . toBeFalsy ( ) ;
1686
1683
} ) ;
1687
1684
1688
1685
1689
1686
it ( 'should load extra modules' , function ( ) {
1690
1687
element = jqLite ( '<div>{{1+2}}</div>' ) ;
1691
- window . name = 'NG_DEFER_BOOTSTRAP!' ;
1688
+ document . cookie = 'NG_DEFER_BOOTSTRAP!=true ' ;
1692
1689
1693
1690
var bootstrapping = jasmine . createSpy ( 'bootstrapping' ) ;
1694
1691
angular . bootstrap ( element , [ bootstrapping ] ) ;
@@ -1716,18 +1713,71 @@ describe('angular', function() {
1716
1713
} ) ;
1717
1714
1718
1715
1719
- it ( 'should restore the original window.name after bootstrap' , function ( ) {
1720
- window . name = 'NG_DEFER_BOOTSTRAP!my custom name ' ;
1716
+ it ( 'should remove the cookie after bootstrap' , function ( ) {
1717
+ document . cookie = 'NG_DEFER_BOOTSTRAP!=true ' ;
1721
1718
angular . bootstrap ( element ) ;
1722
1719
1723
1720
expect ( element . html ( ) ) . toBe ( '{{1+2}}' ) ;
1724
1721
1725
1722
angular . resumeBootstrap ( ) ;
1726
1723
1727
1724
expect ( element . html ( ) ) . toBe ( '3' ) ;
1728
- expect ( window . name ) . toEqual ( 'my custom name' ) ;
1725
+ expect ( / \b N G _ D E F E R _ B O O T S T R A P ! = t r u e \b / . test ( document . cookie ) ) . toBeFalsy ( ) ;
1729
1726
} ) ;
1730
1727
} ) ;
1728
+
1729
+ describe ( 'reloadWithDebugInfo' , function ( ) {
1730
+ var element ;
1731
+
1732
+ beforeEach ( function ( ) {
1733
+ element = jqLite ( '<div>{{1+2}}</div>' ) ;
1734
+ } ) ;
1735
+
1736
+ afterEach ( function ( ) {
1737
+ dealoc ( element ) ;
1738
+ } ) ;
1739
+
1740
+ it ( 'should not change the configuration when the cookie is not set' , function ( ) {
1741
+ var compileProvider = null ;
1742
+
1743
+ bootstrap ( element , [ disableDebugAndGetProvider ] ) ;
1744
+ expect ( compileProvider . debugInfoEnabled ( ) ) . toBeFalsy ( ) ;
1745
+
1746
+ function disableDebugAndGetProvider ( $compileProvider ) {
1747
+ $compileProvider . debugInfoEnabled ( false ) ;
1748
+ compileProvider = $compileProvider ;
1749
+ }
1750
+ } ) ;
1751
+
1752
+ it ( 'should enable debug if the cookie is set' , function ( ) {
1753
+ var compileProvider = null ;
1754
+
1755
+ document . cookie = 'NG_ENABLE_DEBUG_INFO!=true' ;
1756
+ bootstrap ( element , [ getCompileProvider ] ) ;
1757
+
1758
+ expect ( compileProvider . debugInfoEnabled ( ) ) . toBeTruthy ( ) ;
1759
+
1760
+ function getCompileProvider ( $compileProvider ) {
1761
+ compileProvider = $compileProvider ;
1762
+ }
1763
+ } ) ;
1764
+
1765
+ it ( 'should remove the cookie' , function ( ) {
1766
+ document . cookie = 'NG_ENABLE_DEBUG_INFO!=true' ;
1767
+ bootstrap ( element ) ;
1768
+ expect ( document . cookie ) . toEqual ( '' ) ;
1769
+ } ) ;
1770
+ } ) ;
1771
+ } ) ;
1772
+
1773
+ describe ( 'reloadWithDebugInfo' , function ( ) {
1774
+
1775
+ it ( 'should create a cookie' , function ( ) {
1776
+ angular . reloadWithDebugInfo ( ) ;
1777
+ expect ( / \b N G _ E N A B L E _ D E B U G _ I N F O ! = t r u e \b / . test ( document . cookie ) ) . toBeTruthy ( ) ;
1778
+
1779
+ // it should also reload the window, but we can not test that, as window.location can not be spied upon
1780
+ } ) ;
1731
1781
} ) ;
1732
1782
1733
1783
0 commit comments