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

1.1.4 scenario runner does not work in IE (8 -> 10) #2370

@ryanzec

Description

@ryanzec

First let me just mention that this seems to be a specific issue with 1.1.4 as I have tested the same code against 1.0.6 and it works in IE fine.

Here is a very simple angular scenario runner : code for this site can be found here https://github.com/ryanzec/angular-seed :

http://seed.ryanzec.com/scripts/tests/e2e/runner.html

If you load this in Chrome, Firefox, or Safari, its passes without any issues. If you try to run this in IE 8, 9, or 10 (tested in IE 10 using compatible mode to test 8/9) you will get the following error (native IE 8 shows a similar error but does not specify the resumeBootstrap is the property/method that does not exist):

TypeError: Object doesn't support property or method 'resumeBootstrap'

Now while both the angular.js and angular-scenario.js files add the resumeBootstrap method to the angular object, base on my debugging of this issue, this is the location where the resumeBootstrap method gets added to the angular object (lines 975 -> 1008 from angular.js):

function bootstrap(element, modules) {
  var resumeBootstrapInternal = function() {
    element = jqLite(element);
    modules = modules || [];
    modules.unshift(['$provide', function($provide) {
      $provide.value('$rootElement', element);
    }]);
    modules.unshift('ng');
    var injector = createInjector(modules);
    injector.invoke(['$rootScope', '$rootElement', '$compile', '$injector',
       function(scope, element, compile, injector) {
        scope.$apply(function() {
          element.data('$injector', injector);
          compile(element)(scope);
        });
      }]
    );
    return injector;
  };

  var NG_DEFER_BOOTSTRAP = /^NG_DEFER_BOOTSTRAP!/;

  if (window && !NG_DEFER_BOOTSTRAP.test(window.name)) {
    return resumeBootstrapInternal();
  }

  window.name = window.name.replace(NG_DEFER_BOOTSTRAP, '');
  angular.resumeBootstrap = function(extraModules) {
    forEach(extraModules, function(module) {
      modules.push(module);
    });
    resumeBootstrapInternal();
  };
}

I have verified that both Chrome and IE are getting the code block executed however the issue for IE is that the varaible window.name is an empty string and Chrome shows it as NG_DEFER_BOOTSTRAP!. From here I looked to see where the name was getting set and that seems to happen here (lines 26212 -> 26255 in angular-scenario.js):

angular.scenario.Application.prototype.navigateTo = function(url, loadFn, errorFn) {
  var self = this;
  var frame = self.getFrame_();
  //TODO(esprehn): Refactor to use rethrow()
  errorFn = errorFn || function(e) { throw e; };
  if (url === 'about:blank') {
    errorFn('Sandbox Error: Navigating to about:blank is not allowed.');
  } else if (url.charAt(0) === '#') {
    url = frame.attr('src').split('#')[0] + url;
    frame.attr('src', url);
    self.executeAction(loadFn);
  } else {
    frame.remove();
    self.context.find('#test-frames').append('<iframe>');
    frame = self.getFrame_();

    frame[0].contentWindow.name = "NG_DEFER_BOOTSTRAP!";

    frame.load(function() {
      frame.unbind();
      try {
        var $window = self.getWindow_();

        if ($window.angular) {
          // Disable animations

          // TODO(i): this doesn't disable javascript animations
          //          we don't need that for our tests, but it should be done
          $window.angular.resumeBootstrap([['$provide', function($provide) {
            $provide.decorator('$sniffer', function($delegate) {
              $delegate.supportsTransitions = false;
              return $delegate;
            });
          }]]);
        }

        self.executeAction(loadFn);
      } catch (e) {
        errorFn(e);
      }
    }).attr('src', url);
  }
  self.context.find('> h2 a').attr('href', url).text(url);
};

The weird thing is that this line

frame[0].contentWindow.name = "NG_DEFER_BOOTSTRAP!"; 

Seems to be running properly for both Chrome and IE (the console.log()'s I put there output the same) so I am not quite sure why IE is not working. There are only 2 possibilities I can think of (unless this is just an IE bug). One is there is another place that is setting the name that I can't seem to find that IE is not executing. The other is that the value for

frame[0]

Is different for Chrome and IE, maybe IE is not pulling the frame properly, however I don't see any why I can test that.

Now inside the block of code from the angular-scenario.js file, if I change:

if ($window.angular) {

to

if ($window.angular.resumeBootstrap) {

The scenarios run properly on IE however I don't know if this would create other bugs in the scenario runner (at least I know it won't effect my actual production code) so not sure if this is a proper fix (my gut tells me it is not).

Does anyone see what might be the issue here?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions