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

Allow arrays from different frames or contexts to be equal #767

Merged
merged 1 commit into from
Feb 4, 2015

Conversation

juliemr
Copy link

@juliemr juliemr commented Feb 3, 2015

No description provided.

// or `Array`s from different frames are.
var areArrays = className === '[object Array]';
if (!areArrays) {
if (typeof a != 'object' || typeof b != 'object') {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line appears to be a duplicate of line 126

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed.

@Gerg
Copy link
Contributor

Gerg commented Feb 3, 2015

Thanks for the PR.

A couple issues:

  1. I commented on a couple lines with specific questions.
  2. This PR does not include any tests. As per our contribution guide, we require tests, so that there are not future regressions.

For the test, it would be ideal if we could reproduce this issue without relying on Node. If this is not possible, you can add node-specific tests to the npmPackage directory.

@juliemr
Copy link
Author

juliemr commented Feb 4, 2015

Thanks for taking a look!

The two ways that I know to reproduce the issue are

  1. in node with vm (won't work in browser)
  2. using multiple frames (won't work in node)

More context: http://perfectionkills.com/instanceof-considered-harmful-or-how-to-write-a-robust-isarray/

I think my preference would be to add tests to matchersUtilSpec.js which only run if require is available, much like there are now functions which only run if document is available. Does that sound reasonable? If so, I'll go ahead and do that.

@slackersoft
Copy link
Member

That sounds good. I like having the specs be closer to where you would expect to find them for equality.

@juliemr
Copy link
Author

juliemr commented Feb 4, 2015

OK - I've added tests for both the iframes case and the vm case. The iframes case requires appending an element to the DOM, which I clean up at the end of the test - but let me know if you don't like this.

EDIT: as Travis shows, the iframes causes an issue on PhantomJS - preferences? I don't see the use case for having different iframes inside a Jasmine suite, so I'd be tempted to just remove those two tests.

var frame = document.createElement("iframe");
document.body.appendChild(frame);
xObject = window.frames[window.frames.length-1].Object;
var obj = new Object();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should say new xObject() instead of just Object

@slackersoft
Copy link
Member

Given that the fix is the same, let's just go with the vm-based specs and leave the frame based ones out.

@juliemr
Copy link
Author

juliemr commented Feb 4, 2015

OK, removed the iframe based tests.

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.

3 participants