From 7c60e19eb895e2a168b26a0032368a2e0f93b492 Mon Sep 17 00:00:00 2001 From: lucienbertin Date: Thu, 11 Feb 2016 13:49:50 +0100 Subject: [PATCH 1/2] fix(*): only call console.log when window.console exists `window.console` only exists in IE 8 & 9 when the devtools are open Fixes #14006 Closes #14007 Closes #14047 --- src/angular.bind.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/angular.bind.js b/src/angular.bind.js index 33bc710d4342..45bcdecb7247 100644 --- a/src/angular.bind.js +++ b/src/angular.bind.js @@ -1,6 +1,8 @@ if (window.angular.bootstrap) { //AngularJS is already loaded, so we can return here... - console.log('WARNING: Tried to load angular more than once.'); + if (window.console) { + console.log('WARNING: Tried to load angular more than once.'); + } return; } From 3940edced444c0747c7633771fc8f21d3d04e1b3 Mon Sep 17 00:00:00 2001 From: Martin Staffa Date: Mon, 15 Feb 2016 16:45:50 +0100 Subject: [PATCH 2/2] test(*): ensure console log doesn't break the app in IE9 When Angular is loaded more than once (by including the script multiple times), a warning is logged in the console. IE9 only makes the console available when the dev tools are open, so before this fix, the browser would throw an error Note that Protractor doesn't actually support IE9. --- test/e2e/fixtures/angular-already-loaded/index.html | 10 ++++++++++ test/e2e/fixtures/angular-already-loaded/script.js | 4 ++++ test/e2e/tests/angular-already-loadedSpec.js | 10 ++++++++++ 3 files changed, 24 insertions(+) create mode 100644 test/e2e/fixtures/angular-already-loaded/index.html create mode 100644 test/e2e/fixtures/angular-already-loaded/script.js create mode 100644 test/e2e/tests/angular-already-loadedSpec.js diff --git a/test/e2e/fixtures/angular-already-loaded/index.html b/test/e2e/fixtures/angular-already-loaded/index.html new file mode 100644 index 000000000000..292124d4fe1b --- /dev/null +++ b/test/e2e/fixtures/angular-already-loaded/index.html @@ -0,0 +1,10 @@ + + +
+

{{text}}

+
+ + + + + diff --git a/test/e2e/fixtures/angular-already-loaded/script.js b/test/e2e/fixtures/angular-already-loaded/script.js new file mode 100644 index 000000000000..2d625bb4f19c --- /dev/null +++ b/test/e2e/fixtures/angular-already-loaded/script.js @@ -0,0 +1,4 @@ +angular.module("test", []). + controller("TestCtrl", function($scope) { + $scope.text = "Hello, world!"; + }); diff --git a/test/e2e/tests/angular-already-loadedSpec.js b/test/e2e/tests/angular-already-loadedSpec.js new file mode 100644 index 000000000000..87e4d8aabe14 --- /dev/null +++ b/test/e2e/tests/angular-already-loadedSpec.js @@ -0,0 +1,10 @@ +describe('App where angular is loaded more than once', function() { + beforeEach(function() { + loadFixture("angular-already-loaded").andWaitForAngular(); + }); + + it('should have the interpolated text', function() { + expect(element(by.binding('text')).getText()) + .toBe('Hello, world!'); + }); +});