Closed Bug 294673 Opened 20 years ago Closed 19 years ago

Starting Reporter from a blank page shouldn't prefill URL with "about:blank"

Categories

(Other Applications Graveyard :: Reporter, defect)

1.8 Branch
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED
mozilla1.8rc1

People

(Reporter: Waldo, Assigned: Gavin)

References

()

Details

(Keywords: fixed1.8)

Attachments

(4 files, 6 obsolete files)

If you open up Reporter from a blank page, Reporter automatically uses
about:blank as the problem page.  This is wrong, because it's never the site
that's desired.  Additionally, submitting a report with that URL generates an
error for an invalid URL.  Instead, when a blank page is shown the URL field
should be left blank.
Yea.

I've been meaning to get to this.  Is there a method for ensuring that only
proper url's are reported (no internal's or about:)?

It's not critical, as the server knows about this, and kicks those out anyway. 
But it's something we should fix.
So, XULPlanet's got a nice list of all the schemes Mozilla uses:

http://xulplanet.com/references/xpcomref/group_Network.html#Protocols

I think the best bet is just to cherry-pick from the list and choose the ones it
makes sense to allow.
Why don't you just make the URL field editable?  And, I would special case
about:blank since the rest of the browser treats it as special.
I'm ok with special casing about:blank.

Though I don't want the field to be open for edits.  The point of it being read
only is so people don't tamper with it. www.foo.tld/bar/baz!= www.foo.tld.  We
need percision.
Attached patch Patch (obsolete) — Splinter Review
Based on 264562
Comment on attachment 187075 [details] [diff] [review]
Patch

The big question here is: should be totally silent like that?  Or will that
cause confusion?
Attachment #187075 - Flags: review?(mconnor)
(In reply to comment #6)
> The big question here is: should be totally silent like that?  Or will that
> cause confusion?

I'd think the best way to do this would be to enable or disable the menu item
based on the current URI each time the menu containing the reporter item is opened.
(In reply to comment #7)
> I'd think the best way to do this would be to enable or disable the menu item
> based on the current URI each time the menu containing the reporter item is
opened.

My question about that is how would that impact on performance?  Would it
calculate every url entered?  Or would it only render when you open the menu? 
And what about really really long url's?
Status: NEW → ASSIGNED
(In reply to comment #8)
> My question about that is how would that impact on performance?

How much performance is lost when you select a bit of text on a web page, put
focus somewhere, or copy something?  Every time you do so, all the Edit items
related to focus get updated this way (or, more correctly, the <command/>
elements for each gets enabled or disabled appropriately).

> Would it calculate every url entered?

You could have the items updated on each page load if you wanted, and I even
considered suggesting this be done that way.  My suggestion, however, does not
update the menu items every time you load a new page in the browser or switch to
a tab containing a different page.

> Or would it only render when you open the menu?

This suggestion would do it this way, yes.  At least one popular extension whose
behavior depends on the current page's URI does it this way.

> And what about really really long url's?

I'm not sure what you mean.  The size of the URI should have no impact on how
this would be implemented, and the speed difference between small and large URIs
should be negligible.  Besides, I'm pretty sure you'd get the URI the same way
you do now - any performance hit should already be in current code.
(In reply to comment #9)
> > My question about that is how would that impact on performance?
> 
> How much performance is lost when you select a bit of text on a web page, put
> focus somewhere, or copy something?  Every time you do so, all the Edit items
> related to focus get updated this way (or, more correctly, the <command/>
> elements for each gets enabled or disabled appropriately).
> 
Is that chrome code?  Or deeper inside the beast?

> > Or would it only render when you open the menu?
> 
> This suggestion would do it this way, yes.  At least one popular extension whose
> behavior depends on the current page's URI does it this way.
> 
That's how it should be done.  I want reporter to be 0 impact.  Need to figure
out how that's done.

> > And what about really really long url's?
> 
> I'm not sure what you mean.  The size of the URI should have no impact on how
> this would be implemented, and the speed difference between small and large URIs
> should be negligible.  Besides, I'm pretty sure you'd get the URI the same way
> you do now - any performance hit should already be in current code.

well, in theory, indexOf() on a 3 char string is quicker than 3.02x10^23.
(In reply to comment #10)
> Is that chrome code?  Or deeper inside the beast?

That's all in js chrome files.

> well, in theory, indexOf() on a 3 char string is quicker than 3.02x10^23.

Oops - didn't notice you were using indexOf().  You should be using
getBrowser().currentURI.schemeIs("foo") instead, which will be faster because
it's preconstructed in the currentURI XPConnect-wrapped nsIURI.
(In reply to comment #11)
> You should be using getBrowser().currentURI.schemeIs("foo") instead

...or perhaps getBrowser.currentURI.scheme and then just compare it in JS.  (/me
stops spamming now)
Attachment #187075 - Attachment is obsolete: true
Attachment #187075 - Flags: review?(mconnor)
Attached patch Patch v2 (obsolete) — Splinter Review
Attachment #193406 - Flags: review+
Attachment #193406 - Flags: review+ → review-
Attached patch Patch v2.1 (obsolete) — Splinter Review
Fixes some stupid mistakes (lack of sleep, and a long break from coding isn't
good).
Attachment #193406 - Attachment is obsolete: true
Comment on attachment 193409 [details] [diff] [review]
Patch v2.1

Gavin has a better patch
Attachment #193409 - Attachment is obsolete: true
Sorry, I've been too busy lately, I'll post the patch tonight.
Attached patch alternate patch (obsolete) — Splinter Review
Assignee: robert → gavin.sharp
Attached patch alternate patch v2 (obsolete) — Splinter Review
Fixes a mistake with the last patch. Not sure who should review this.
Attachment #194383 - Attachment is obsolete: true
Gavin: I won't be around much wed/thurs thanks to IBM not fixing my laptop the
first time around... but will be back around thurs evening.

I want this patch in, so if your comfortable that this works with no
regressions, you can r=me if you want (feel free to get another review if you
want a better set of eyes looking at it).  I can't test it, so I'd leave that to
you.  I don't see anything obvious from looking at your patch.  

Ask Asa for approval on the branch.
Flags: blocking1.8b4?
Oh yea... thanks for getting to this

/me grumbles about "depot repair" not being very good... and the desire to have
a dev system again.
Seems like an edge case - is there a more common scenerio here that is tripping
you up?   Also need a review from MConnor when he's back next week.

Flags: blocking1.8b4? → blocking1.8b4-
Comment on attachment 194405 [details] [diff] [review]
alternate patch v2

Fixes this bug, and also the disabled style for the toolbar button.
Attachment #194405 - Flags: review?(mconnor)
Whiteboard: [patch-r?]
Comment on attachment 194405 [details] [diff] [review]
alternate patch v2

>Index: extensions/reporter/resources/content/reporter/reporterOverlay.js

>+function onBrowserLoad() {
>+  const nsIWebProgress = Components.interfaces.nsIWebProgress;
>+  gBrowser.addProgressListener(reporterListener, nsIWebProgress.NOTIFY_LOCATION);
>+}

No need for the nsIWebProgress.NOTIFY_LOCATION here, this addProgressListener
only takes a listner and automatically passes _ALL.
Gavin, land this when possible.  Get asa's approval for the branch.
this really is just polish... can we perhaps get this in?  mconnor? gavin?
Flags: blocking1.8rc1?
I get a hung reporter window when I try to send in a report for about:blank and
get the error that it's an invalid URL. We need to fix that problem for sure.
Flags: blocking1.8rc1? → blocking1.8rc1+
Target Milestone: --- → mozilla1.8rc1
Version: unspecified → 1.8 Branch
Comment on attachment 194405 [details] [diff] [review]
alternate patch v2

>-function loadReporterWizard()
>-{
>-  window.openDialog("chrome://reporter/content/reportWizard.xul", "", "chrome,centerscreen,dialog,resizable=no,width=535,height=442",getBrowser().currentURI.spec);
>+  QueryInterface: function(aIID) {
>+   if (aIID.equals(Components.interfaces.nsIWebProgressListener) ||
>+       aIID.equals(Components.interfaces.nsISupportsWeakReference) ||
>+       aIID.equals(Components.interfaces.nsISupports))
>+     return this;
>+   throw Components.results.NS_NOINTERFACE;
>+  },

nit: indentation is off by one.

>+  onLocationChange: function(aProgress, aRequest, aURI) {
>+    var broadcaster = document.getElementById("reporterItemsBroadcaster");
>+    // XXX The schemeIs check is only necessary until bug 169826 is fixed,
>+    // since we can end up with a dummy URI here
>+    var isEnabled = (aURI && "schemeIs" in aURI &&
>+                     (aURI.schemeIs("http") ||
>+                      aURI.schemeIs("https") ||
>+                      aURI.schemeIs("ftp") ||
>+                      aURI.schemeIs("gopher")));

is schemeIs expensive here?  is a switch statement faster (this will get called
a lot)

r=me with comments addressed.
Attachment #194405 - Flags: review?(mconnor) → review+
(In reply to comment #27)
> is schemeIs expensive here?  is a switch statement faster (this will get called
> a lot)

The four schemeIs()s were faster in my limited testing, though it shouldn't
matter that much since it's being called frequently but not in rapid succession.
New patch coming up.
Whiteboard: [patch-r?]
Attached patch for checkinSplinter Review
Attachment #194405 - Attachment is obsolete: true
Trunk:

mozilla/extensions/reporter/resources/content/reporter/reporterOverlay.js
new revision: 1.3; previous revision: 1.2
mozilla/extensions/reporter/resources/content/reporter/reporterOverlay.xul
new revision: 1.6; previous revision: 1.5
mozilla/extensions/reporter/resources/skin/classic/reporter/browserOverlay.css
new revision: 1.2; previous revision: 1.1
Status: ASSIGNED → RESOLVED
Closed: 19 years ago
Resolution: --- → FIXED
Attachment #199375 - Flags: approval1.8rc1?
(In reply to comment #28)
> (In reply to comment #27)
> > is schemeIs expensive here?  is a switch statement faster (this will get called
> > a lot)
> 
> The four schemeIs()s were faster in my limited testing,

That's surprising.  Can you attach the alterna-patch that used switch?

/be
Attached patch use switch instead (obsolete) — Splinter Review
Sure. My "limited testing" was sythethic, whether it was representative of
real-world use or not is questionable, I guess, and may have been flawed. If
you prefer this one, here it is.
Make that |    switch (aURI.scheme || null) {| to avoid the warning.
Attached file switch-based benchmark
schemeIs || chain benchmark next.

/be
Attached file schemeIs benchmark
Best of 3 in xpcshell, switch time: 441ms, schemeIs time: 767ms -- switch wins,
as expected by me, at least!

/be
Changing the URI passed to init to be file: (to mismatch all switch cases and
fail all schemeIs tests), best of 3 in xpcshell, switch: 417ms vs. schemeIs:
2886ms(!).

Review-stamping switch patch and nominating it.

/be
(In reply to comment #33)
> Make that |    switch (aURI.scheme || null) {| to avoid the warning.

Why is this necessary?

Was the schemeIs approach checked into the trunk?  It looks like it.  Reopening
to get the switch approach in.

/be
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
Attachment #199381 - Flags: review+
Attachment #199381 - Flags: approval1.8rc1?
Checked in the switch patch, without the || null. Thanks again!
Status: REOPENED → RESOLVED
Closed: 19 years ago19 years ago
Resolution: --- → FIXED
Attachment #199375 - Flags: approval1.8rc1?
Attachment #199381 - Attachment is obsolete: true
Attachment #199381 - Flags: approval1.8rc1?
(In reply to comment #37)
> (In reply to comment #33)
> > Make that |    switch (aURI.scheme || null) {| to avoid the warning.
> 
> Why is this necessary?

Because of bug 312260.

/be
Attachment #199386 - Flags: approval1.8rc1? → approval1.8rc1+
Checked in on the branch, with tweak from bug 312353.

mozilla/extensions/reporter/resources/content/reporter/reporterOverlay.js
new revision: 1.2.10.1; previous revision: 1.2
mozilla/extensions/reporter/resources/content/reporter/reporterOverlay.xul
new revision: 1.5.2.1; previous revision: 1.5
mozilla/extensions/reporter/resources/skin/classic/reporter/browserOverlay.css
new revision: 1.1.12.1; previous revision: 1.1
Keywords: fixed1.8
gavin: thanks for taking care of this.
Product: Other Applications → Other Applications Graveyard
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: