Repository: angular/angular.js
File: test/ng/compileSpec.js (JavaScript)

Code before:
            '<span>dorothy</span>' +
            '<minion>kevin</minion>' +
          '</minion-component>')($rootScope);
        $rootScope.$apply();
        expect(element.children().eq(0).text()).toEqual('default boss content');
        expect(element.children().eq(1).text()).toEqual('stuartkevin');
        expect(element.children().eq(2).text()).toEqual('dorothy');
      });
    });
  });

  describe('*[src] context requirement', function() {

    it('should NOT require trusted values for img src', inject(function($rootScope, $compile, $sce) {
      element = $compile('<img src="{{testUrl}}"></img>')($rootScope);
      $rootScope.testUrl = 'http://example.com/image.png';
      $rootScope.$digest();
      expect(element.attr('src')).toEqual('http://example.com/image.png');
      // But it should accept trusted values anyway.
      $rootScope.testUrl = $sce.trustAsUrl('http://example.com/image2.png');
      $rootScope.$digest();
      expect(element.attr('src')).toEqual('http://example.com/image2.png');
    }));

    // IE9 rejects the video / audio tag with "Error: Not implemented" and the source tag with
    // "Unable to get value of the property 'childNodes': object is null or undefined"
    if (!msie || msie > 9) {
      they('should NOT require trusted values for $prop src', ['video', 'audio', 'source'],
      function(tag) {
        inject(function($rootScope, $compile, $sce) {
          element = $compile('<' + tag + ' src="{{testUrl}}"></' + tag + '>')($rootScope);
          $rootScope.testUrl = 'http://example.com/image.mp4';
          $rootScope.$digest();
          expect(element.attr('src')).toEqual('http://example.com/image.mp4');

          // But it should accept trusted values anyway.
          $rootScope.testUrl = $sce.trustAsUrl('http://example.com/image2.mp4');
          $rootScope.$digest();
          expect(element.attr('src')).toEqual('http://example.com/image2.mp4');

          // and trustedResourceUrls for retrocompatibility
          $rootScope.testUrl = $sce.trustAsResourceUrl('http://example.com/image3.mp4');
          $rootScope.$digest();
          expect(element.attr('src')).toEqual('http://example.com/image3.mp4');
        });
      });
    }
  });

  describe('img[src] sanitization', function() {


Review comment (suggestion):
The OP answered that adding a DOCTYPE helped. Do our test cases not have a DOCTYPE? If that's the case we should definitely add them, we should make sure all our tests are running in standards mode, not quirks mode that we don't even officially support AFAIK.

All IE versions older than 10 in quirks mode invoke a separate engine simulating IE 5.5 and, as a consequence, missing features from newer versions (including `<video>` and `<audio>`, obviously).


Code after:
            '<span>dorothy</span>' +
            '<minion>kevin</minion>' +
          '</minion-component>')($rootScope);
        $rootScope.$apply();
        expect(element.children().eq(0).text()).toEqual('default boss content');
        expect(element.children().eq(1).text()).toEqual('stuartkevin');
        expect(element.children().eq(2).text()).toEqual('dorothy');
      });
    });
  });

  describe('*[src] context requirement', function() {

    it('should NOT require trusted values for img src', inject(function($rootScope, $compile, $sce) {
      element = $compile('<img src="{{testUrl}}"></img>')($rootScope);
      $rootScope.testUrl = 'http://example.com/image.png';
      $rootScope.$digest();
      expect(element.attr('src')).toEqual('http://example.com/image.png');
      // But it should accept trusted values anyway.
      $rootScope.testUrl = $sce.trustAsUrl('http://example.com/image2.png');
      $rootScope.$digest();
      expect(element.attr('src')).toEqual('http://example.com/image2.png');
    }));

    // IE9 rejects the video / audio tag with "Error: Not implemented" and the source tag with
    // "Unable to get value of the property 'childNodes': object is null or undefined"
    if (!msie || msie > 9) {
      they('should NOT require trusted values for $prop src', ['video', 'audio'],
      function(tag) {
        inject(function($rootScope, $compile, $sce) {
          element = $compile('<' + tag + ' src="{{testUrl}}"></' + tag + '>')($rootScope);
          $rootScope.testUrl = 'http://example.com/image.mp4';
          $rootScope.$digest();
          expect(element.attr('src')).toEqual('http://example.com/image.mp4');

          // But it should accept trusted values anyway.
          $rootScope.testUrl = $sce.trustAsUrl('http://example.com/image2.mp4');
          $rootScope.$digest();
          expect(element.attr('src')).toEqual('http://example.com/image2.mp4');

          // and trustedResourceUrls for retrocompatibility
          $rootScope.testUrl = $sce.trustAsResourceUrl('http://example.com/image3.mp4');
          $rootScope.$digest();
          expect(element.attr('src')).toEqual('http://example.com/image3.mp4');
        });
      });

      they('should NOT require trusted values for $prop src', ['source', 'track'],
      function(tag) {
        inject(function($rootScope, $compile, $sce) {
          element = $compile('<video><' + tag + ' src="{{testUrl}}"></' + tag + '></video>')($rootScope);