Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit fa3f149

Browse files
committed
fix(Angular.js): use cookie instead of window.name to load with debug info
Use cookie to store a check if the application needs to be loaded with debug info, instead of using window.name. As window.name can be used alread (and be overwritten on page load) Fixes issue #13031
1 parent 18e2afc commit fa3f149

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed

test/AngularSpec.js

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1826,6 +1826,7 @@ describe('angular', function() {
18261826

18271827
expect(element.html()).toBe('3');
18281828
expect(/\bNG_DEFER_BOOTSTRAP!=true\b/.test(document.cookie)).toBeFalsy();
1829+
<<<<<<< HEAD
18291830
});
18301831
});
18311832

@@ -1870,8 +1871,63 @@ describe('angular', function() {
18701871
bootstrap(element);
18711872

18721873
expect(document.cookie).toEqual('');
1874+
=======
1875+
>>>>>>> fix(Angular.js): use cookie instead of window.name to load with debug info
18731876
});
18741877
});
1878+
1879+
describe('reloadWithDebugInfo', function() {
1880+
var element;
1881+
1882+
beforeEach(function() {
1883+
element = jqLite('<div>{{1+2}}</div>');
1884+
});
1885+
1886+
afterEach(function() {
1887+
dealoc(element);
1888+
});
1889+
1890+
it('should not change the configuration when the cookie is not set', function() {
1891+
var compileProvider = null;
1892+
1893+
bootstrap(element, [disableDebugAndGetProvider]);
1894+
expect(compileProvider.debugInfoEnabled()).toBeFalsy();
1895+
1896+
function disableDebugAndGetProvider($compileProvider) {
1897+
$compileProvider.debugInfoEnabled(false);
1898+
compileProvider = $compileProvider;
1899+
}
1900+
});
1901+
1902+
it('should enable debug if the cookie is set', function() {
1903+
var compileProvider = null;
1904+
1905+
document.cookie = 'NG_ENABLE_DEBUG_INFO!=true';
1906+
bootstrap(element, [getCompileProvider]);
1907+
1908+
expect(compileProvider.debugInfoEnabled()).toBeTruthy();
1909+
1910+
function getCompileProvider($compileProvider) {
1911+
compileProvider = $compileProvider;
1912+
}
1913+
});
1914+
1915+
it('should remove the cookie', function() {
1916+
document.cookie = 'NG_ENABLE_DEBUG_INFO!=true';
1917+
bootstrap(element);
1918+
expect(document.cookie).toEqual('');
1919+
});
1920+
});
1921+
});
1922+
1923+
describe('reloadWithDebugInfo', function() {
1924+
1925+
it('should create a cookie', function() {
1926+
angular.reloadWithDebugInfo();
1927+
expect(/\bNG_ENABLE_DEBUG_INFO!=true\b/.test(document.cookie)).toBeTruthy();
1928+
1929+
// it should also reload the window, but we can not test that, as window.location can not be spied upon
1930+
});
18751931
});
18761932

18771933

0 commit comments

Comments
 (0)