Closed Bug 43652 Opened 24 years ago Closed 24 years ago

javascript: js in <a> tag clears window when executed

Categories

(Core :: Networking, defect, P1)

x86
Windows 2000
defect

Tracking

()

VERIFIED FIXED

People

(Reporter: sean, Assigned: mscott)

References

()

Details

(Whiteboard: [nsbeta2+])

Attachments

(1 file)

Clean build pulled 6/23 around 10:30am pacific.

Possibly a regression of http://bugzilla.mozilla.org/show_bug.cgi?id=34217.
Slightly different as the js DOES execute, but the window is cleared and the 
location gets set to the script that ran.
nominating nsbeta2
Keywords: nsbeta2
Using "javascript:..." as the URL parameter to nsIPluginManager::GetURL() with 
a target of "_self" also shows the same behaviour. Setting 
the 'Force_Javascript' parameter to true doesn't fix the problem
Cc:ing valiski since his checkin on 06/16/2000 14:46 to mozilla/netwerk/base/
src/nsFileTransport.cpp, v1.79, broke the javascript: URL's. Also cc:ing warren
since he fixed this problem once before.
This simply *must* be fixed for beta2, period.
Priority: P3 → P1
that change 
(http://bonsai.mozilla.org/cvsview2.cgi?diff_mode=context&whitespace_mode=show&f
ile=nsFileTransport.cpp&root=/cvsroot&subdir=mozilla/netwerk/base/src&command=DI
FF_FRAMESET&rev1=1.78&rev2=1.79) was to fire OnStart() *always.* The consumer 
needs to accommodate the OnStart() that it wasn't getting before.
Putting on [nsbeta2+] radar for beta2 fix. 
Whiteboard: [nsbeta2+]
*** Bug 43708 has been marked as a duplicate of this bug. ***
*** Bug 43708 has been marked as a duplicate of this bug. ***
jud: who is the *consumer* here? the webshell? so who gets this bug? rpotts?
*** Bug 44214 has been marked as a duplicate of this bug. ***
Blocks: 43606
not sure actually, mscott maybe?
*** Bug 43851 has been marked as a duplicate of this bug. ***
nsDocumentOpenInfo::OnStartRequest() (in uriloader/base/nsURILoader.cpp) needs
to be able to get at the NS_ERROR_DOM_RETVAL_UNDEFINED error code returned from
nsJSThunk::Open() (in dom/src/jsurl/nsJSProtocolHandler.cpp), called from
nsFileTransport::Process(). If that's possible then we could check for that and
do nothin in OnStartRequest() in that case, this would fix this problem unless I
missed something here...
->mscott
Assignee: gagan → mscott
Here's the problem:
1) the file channel does indeed set it's status correctly using
NS_ERROR_DOM_RETVAL_UNDEFINED.

2) However, the JS channel is a nsIOStreamChannel which wraps the file channel.
The uri loader only sees the JS channel.

3) Unfortunately, the status for the JS channel is not correctly set to
NS_ERROR_DOM_RETVAL_UNDEFINED. It's always NS_SUCCESS. So the uri loader doesn't
know to not propogate the OnStartRequest.

This appears to be a bug between the file transport setting the right code and
reflecting that back up in the channel that wraps the file transport
(nsIOStreamChannel). Who owns that?
I think it would work if nsStreamIOChannel::GetStatus was modified to instead of
looking at it's own mStatus, return the status of the file transport instead.
But this breaks the case where mStatus for the io channel has a value.

Or maybe, if mStatus is NS_SUCCESS(mStatus) then return the status of the file
transport. That would preserve the semantics of mStatus while allowing us to get
at the value for the transport channel.

Here's the current version:
NS_IMETHODIMP
nsStreamIOChannel::GetStatus(nsresult *status)
{
    *status = mStatus;
    return NS_OK;
}

I'm arguing that we need
if (NS_SUCCEEDED(rv))
  *status = the status for mFileTransport
else
  *status = mStatus;

Warren, do you buy off on that?
Attached patch proposed fixSplinter Review
I re-implemented nsStreamIOChannel::GetStatus to return the status of the file
transport channel if it didn't have a non-error status code for its mStatus.

JS urls are now working again for me including this test case.

Warren, can you gimme a code review on the nsStreamIOChannel change?
Status: NEW → ASSIGNED
Target Milestone: --- → M17
You should check the result value of aChannel->GetStatus(&rv) in 
nsURILoader.cpp just to be safe. Also, I think GetStatus should probably look 
like this:

  if (mFileTransport)
    rv = mFileTransport->GetStatus(status);
  else
    *status = mStatus;

Hey Warren, I already added code to the uriloader to check for the status on the 
channel and to explicilty check for NS_ERROR_DOM_RETVAL_UNDEFINED. My problem 
was that the nsIOStreamChannel wasn't giving me this value. 

this change fixes the problem.

Can I consider this reviewed then? (including your suggestion) thanks man.
Oh wait, Warren, the reason I didn't write the code the way you just did is 
because now you are losing mStatus if it was given an error code. If you search 
through the code in nsStreamIOchannel you'll see that in several cases mStatus 
is set with error codes (particularly in the cancel case). My patch works around 
that by preserving the value of mStatus and using it if it isn't a success 
value. By making your suggested change, we break the semantics of mStatus in 
nsStreamIOchannel and will incorrectly miss error values.
I thought I saw that mStatus was only set by cancel. We could almost remove it 
entirely since canceling one of these without a transport is pretty meaningless 
(could return an error). But your patch is ok with me.
*** Bug 44767 has been marked as a duplicate of this bug. ***
Fix checked in. This test js url is now working like it should for me. 
Status: ASSIGNED → RESOLVED
Closed: 24 years ago
Resolution: --- → FIXED
*** Bug 44812 has been marked as a duplicate of this bug. ***
*** Bug 45004 has been marked as a duplicate of this bug. ***
verif.
Win2000 2000071008
Linux 2000071008
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: