Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Work-around to avoid "Unsafe JavaScript attempt to access frame" warning #16

Closed
wants to merge 1 commit into from

Conversation

nobuoka
Copy link

@nobuoka nobuoka commented Nov 5, 2014

Problem

Using gulp-qunit 1.0.0 with PhantomJS 1.9.12, following warning is output.

Unsafe JavaScript attempt to access frame with URL about:blank from frame with URL file:///path/to/node_modules/gulp-qunit/runner.js. Domains, protocols and ports must match.

This is a issue of PhantomJS. Please see: ariya/phantomjs#12697

Change

I add work-around to avoid "Unsafe JavaScript attempt to access frame" warning.

Tests

We can confirm that "Unsafe JavaScript attempt to access frame" warning is avoided by this change:
(I think test is not needed, so this change was not committed.)

diff --git a/test/main.js b/test/main.js
index a21eb24..290960e 100644
--- a/test/main.js
+++ b/test/main.js
@@ -10,15 +10,19 @@ var assert = require('assert'),
     out = process.stdout.write.bind(process.stdout);

 describe('gulp-qunit', function() {
+    function assertUnsafeJSAttemptToAccessFrameWarningNotExist(msg) {
+        return !/Unsafe JavaScript attempt to access frame with URL about:blank from frame with URL/.test(msg)
+    }
+
     it('tests should pass', function(cb) {
         this.timeout(5000);

         var stream = qunit();

         process.stdout.write = function (str) {
-            //out(str);
+            out(str);

-            if (/10 passed. 0 failed./.test(str)) {
+            if (/10 passed. 0 failed./.test(str) && assertUnsafeJSAttemptToAccessFrameWarningNotExist(str)) {
                 assert(true);
                 process.stdout.write = out;
                 cb();
@@ -39,9 +43,9 @@ describe('gulp-qunit', function() {
         var stream = qunit({'phantomjs-options': ['--ssl-protocol=any']});

         process.stdout.write = function (str) {
-            //out(str);
+            out(str);

-            if (/10 passed. 0 failed./.test(str)) {
+            if (/10 passed. 0 failed./.test(str) && assertUnsafeJSAttemptToAccessFrameWarningNotExist(str)) {
                 assert(true);
                 process.stdout.write = out;
                 cb();
@@ -62,9 +66,9 @@ describe('gulp-qunit', function() {
         var stream = qunit();

         process.stdout.write = function (str) {
-            //out(str);
+            out(str);

-            if (/10 passed. 0 failed./.test(str)) {
+            if (/10 passed. 0 failed./.test(str) && assertUnsafeJSAttemptToAccessFrameWarningNotExist(str)) {
                 assert(true);
                 process.stdout.write = out;
                 cb();
@@ -89,9 +93,9 @@ describe('gulp-qunit', function() {
         });

         process.stdout.write = function (str) {
-            //out(str);
+            out(str);

-            if (/10 passed. 0 failed./.test(str)) {
+            if (/10 passed. 0 failed./.test(str) && assertUnsafeJSAttemptToAccessFrameWarningNotExist(str)) {
                 assert(true);
                 process.stdout.write = out;
                 cb();

Thanks.

@jonkemp
Copy link
Owner

jonkemp commented Nov 6, 2014

I'm more inclined to see if they fix this with the next update. Anyone that wants to fix this locally can just make this change themselves.

@jonkemp
Copy link
Owner

jonkemp commented Dec 16, 2014

Closing. This can no longer be merged as this code is now pulled in as a dependency. And that codebase already has a similar pull request jonkemp/qunit-phantomjs-runner#5.

@jonkemp jonkemp closed this Dec 16, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants