Skip to content
This repository has been archived by the owner on May 30, 2023. It is now read-only.

for..in arguments statement problem #10315

Closed
nicusg opened this issue Dec 21, 2011 · 5 comments
Closed

for..in arguments statement problem #10315

nicusg opened this issue Dec 21, 2011 · 5 comments

Comments

@nicusg
Copy link

nicusg commented Dec 21, 2011

nicu.gir...@sendgrid.com commented:

Which version of PhantomJS are you using? Tip: run 'phantomjs 1.3 version'.

What steps will reproduce the problem?

  1. extract files
  2. run: phantomjs run-qunit.js testme.test.htm

What is the expected output?
Test "add is defined" completed: pass
Test "add 1+1" completed: pass
'waitFor()' finished in 212ms.
Tests completed in 33 milliseconds.
2 tests of 2 passed, 0 failed.

What do you see instead?
Test "add is defined" completed: pass
Test "add 1+1" assertion failed. Expected <2> Actual <0>
Test "add 1+1" completed: FAIL
'waitFor()' finished in 223ms.
Tests completed in 34 milliseconds.
1 tests of 2 passed, 1 failed.

Which operating system are you using?
Windows 7

Did you use binary PhantomJS or did you compile it from source?
Binary

Please provide any additional information below.
In the add function, if you replace the for statement with:
for(var i=0;i<arguments.length;i++)
then the output is correct.
The issue is only in the arguments object. For any other object it works correctly

Disclaimer:
This issue was migrated on 2013-03-15 from the project's former issue tracker on Google Code, Issue #315.
🌟   2 people had starred this issue at the time of migration.

@ariya
Copy link
Owner

ariya commented Nov 1, 2012

ariya.hi...@gmail.com commented:

Can you try it with the latest version?

@Krinkle
Copy link

Krinkle commented May 23, 2014

The issue is still there.

function x() {
    for ( var key in arguments ) {}
    return key;
}
x('foo', 'bar', 'baz');
// Chrome>
"2"
// PhantomJS>
undefined
function x() {
    return String(arguments);
}
x('foo', 'bar', 'baz');
// Chrome>
'[object Arguments]'
// PhantomJS>
'[object Arguments]'
function x() {
    return JSON.stringify(arguments);
}
x('foo', 'bar', 'baz');
// Chrome>
'{"0":"foo","1":"bar","2":"baz"}'
// PhantomJS>
'{}'

@nicusg nicusg closed this as completed May 26, 2014
@JamesMGreene JamesMGreene reopened this May 27, 2014
@JamesMGreene
Copy link
Collaborator

@Krinkle: Are you using the PhantomJS REPL or an actual driver script?

@Krinkle
Copy link

Krinkle commented May 27, 2014

@JamesMGreene Tried in both REPL and regular script execution on a web page (PhantomJS v1.9.7). Same results (missing keys).

@vitallium
Copy link
Collaborator

Works in 2.0.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants