Closed Bug 284505 Opened 20 years ago Closed 6 years ago

Some date functions returning double values (300.0) where integers should be (300)

Categories

(Rhino Graveyard :: Core, defect, P5)

x86
Linux
defect

Tracking

(Not tracked)

RESOLVED INACTIVE

People

(Reporter: dave.damon, Unassigned)

References

()

Details

User-Agent:       Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.5) Gecko/20041107 Firefox/1.0
Build Identifier: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.5) Gecko/20041107 Firefox/1.0

The specified URL has a hidden timezone field (tz).  This value is set using
javascript.  My time zone offset is 300, but rhino sets the timezone as 300.0. 
The server returns an HTTP 500 (Internal error) when the form is posted since it
is expecting an integer in the tz field.
Browsers populate this field with a integer value as expected.



Reproducible: Always

Steps to Reproduce:
1.make sure you have ssl support.
2.run the following beanshell script.... - or wrap it in a class and run it.
3. script follows:
import junit.framework.*;
import com.meterware.httpunit.*;
import org.w3c.dom.Document;

HttpUnitOptions.setExceptionsThrownOnScriptError( false );

WebConversation wc = new WebConversation();
WebRequest req = new GetMethodWebRequest( "http://www.hypersend.com" );
WebResponse res = wc.getResponse( req );

WebLink[] links = res.getLinks();

for( int i = 0; i < links.length; ++i ) {
  if( links[ i ].getURLString().matches( ".*Login.*" )) {
    res = links[ i ].click();
    break;
  }
}


WebForm[] forms = res.getForms();
print( forms.length );
WebForm loginForm = forms[ 0 ];

loginForm.setParameter( "user_email",    "henry@henryford.com" );
loginForm.setParameter( "user_password", "undisclosed" );
loginForm.setParameter( "tz", "" );

SubmitButton[] subs = forms[ 0 ].getSubmitButtons();
SubmitButton loginBtn = null;

for( int i = 0; i < subs.length; ++i ) {
  if( subs[ i ].getName().matches( "btnLogin" )) {
    loginBtn = subs[ i ];
    break;
  }
}

loginBtn.click();

Actual Results:  
server returns an INternal error (500) after the loginBtn.click() call.

Expected Results:  
If you have a proper username and password, it should log in.  This particular
script (having invalid username and password) should return you to the login
page saying your login was invalid.

I have a fixed version of rhino that handles this fine.
I modified NativeDate.java 
method:
     public Object execIdCall( IdFunctionObject f,
                               Context cx,
                               Scriptable scope,
                               Scriptable thisObj,
                               Object[] args)

so that date functions that can return integers, do.  I did this by calling
wrapInt() rather than wrapNumber() at appropriate points.
Forgot to mention... the test script makes use of httpunit.
Could you submit a patch as per <http://www.mozilla.org/hacking/life-cycle.html>
 ?
Reassigning to please_see_bug_288433@eml.cc pending resolution of bug 288433
Assignee: igor.bukanov → please_see_bug_288433
Assignee: please_see_bug_288433 → nobody
Changing priority to P5 based on recent bug triage.
Priority: -- → P5

Closing. Bug management is now done here:
https://github.com/mozilla/rhino

Status: NEW → RESOLVED
Closed: 6 years ago
Resolution: --- → INACTIVE
You need to log in before you can comment on or make changes to this bug.