jfirebaugh / konacha

Test your Rails application's JavaScript with the mocha test framework and chai assertion library
Other
1.05k stars 117 forks source link

Konacha fails if browser uses extensions that add iframe #195

Open paneq opened 9 years ago

paneq commented 9 years ago

I experience:

Uncaught SecurityError: Blocked a frame with origin "http://localhost:3500" from accessing a frame with origin "chrome-extension://noojglkidnpfjbincgijbaiedldjfbhh".  The frame requesting access has a protocol of "http", the frame being accessed has a protocol of "chrome-extension". Protocols must match.

in google chrome in code:

// Check that all iframes loaded successfully.
  var iframes = document.getElementsByTagName('iframe');
  for (var i = 0; i < iframes.length; ++i) {
    if (!iframes[i].contentWindow.mocha) {
      (function (path) {
        mocha.suite.addTest(new Mocha.Test(path, function () {
          throw new Error("Failed to load " + path + ".\n" +
                          "Perhaps it failed to compile? Check the rake output for errors.");
        }));
      })(iframes[i].getAttribute("data-path"));
    }
  }

My workaround is to run the tests in incognito window where all extensions are disabled.

jfirebaugh commented 9 years ago

I guess the way to work around this would be to check the scheme and host of the iframe before trying to access contentWindow. Happy to accept a pull request that does so.