Closed Bug 566084 Opened 14 years ago Closed 13 years ago

Highlighter should be disabled when navigating to new pages

Categories

(DevTools :: General, defect, P1)

defect

Tracking

(Not tracked)

VERIFIED FIXED
Firefox 9

People

(Reporter: ehsan.akhgari, Assigned: msucan)

References

Details

(Whiteboard: [strings][minotaur][fixed-in-fx-team][qa+])

Attachments

(1 file, 15 obsolete files)

14.17 KB, patch
dao
: review+
Details | Diff | Splinter Review
This is very similar to bug 566082, with the same set of STR.  Basically, the panel just stays there, showing info from the old page, and the element highlighting UI doesn't get activated again.
Need to an a location changed listener to the inspector. We would either want to close the inspector on navigation to a new page or reinitialize on the new page. Probably the former, I think.
Assignee: nobody → rcampbell
OS: Mac OS X → All
Hardware: x86 → All
test-case failing when navigating away from a test page to another with the highlighter open.
Attachment #454601 - Flags: review?(gavin.sharp)
Attached patch onreadystatechange (obsolete) — Splinter Review
simple patch to close the inspector onreadystatechange.
Attachment #454626 - Flags: review?(gavin.sharp)
another nice feature might be to display a notification that you're about to navigate away from a webpage and close the inspector.
throwing this back into the pool...
Assignee: rcampbell → nobody
Attachment #454626 - Flags: review?(gavin.sharp)
Comment on attachment 454626 [details] [diff] [review]
onreadystatechange

this patch doesn't work. I thought I might get an easy out with something like this, but I think we'll need a web progress listener to detect navigation away from the page.
Assignee: nobody → mihai.sucan
Attached patch patch + test code (obsolete) — Splinter Review
This is the patch + test code that fixes this bug, as discussed with Robert on IRC. This patch should apply cleanly on mozilla-central default branch.

The previous test code and fix files are both obsolete. The bug fix approach is different now, and the test code has changed a lot to be able to properly test the fix.

Any feedback for improvements is very much welcome, thanks!
Attachment #454601 - Attachment is obsolete: true
Attachment #454626 - Attachment is obsolete: true
Attachment #461008 - Flags: feedback?(rcampbell)
Attachment #454601 - Flags: review?(gavin.sharp)
blocking2.0: --- → ?
Comment on attachment 461008 [details] [diff] [review]
patch + test code

In inspector.js,

+    gBrowser.addProgressListener(InspectorProgressListener,
+        Ci.nsIWebProgress.NOTIFY_STATE_DOCUMENT);
...
+    gBrowser.removeProgressListener(InspectorProgressListener);

I don't think we want to be notified of changes on all tabs, do we? Can we do gBrowser.selectedTab.addProgressListener() instead? (Might need to use the this.browser element, not sure which one of these will work)

+  onStateChange: function IPL_onStateChange(aProgress, aRequest, aFlag, aStatus) {
+    // remove myself if the Inspector is no longer open.
+    if (!InspectorUI.isPanelOpen) {
+      gBrowser.removeProgressListener(InspectorProgressListener);
+      return;

and here.

+    // Unknown values are considered 0.
+    if (!pref || (pref != 1 && pref != 2)) {

this is confusing logic. If you want undefined or 0,

  if (!pref) { ...

+      let prompts = Cc["@mozilla.org/embedcomp/prompt-service;1"].
+          getService(Ci.nsIPromptService);

Services.prompt. No need to create a variable since you can look it up directly.

+    }
+
+    if (pref == 1) {

  } else if (pref == 1) {

+    } else if (pref == 2) {
+      // The pref is set to never confirm page navigation.
+      BrowserStop();
+    }

maybe include an extra else clause here to do defaults and sanity checking on the stored pref. Chances are, if the pref was set to something > 2, they probably wanted never confirm. 

+  onLocationChange: function() {},    <- trailing whitespace
+  onProgressChange: function() {},

in the inspector.properties file.

+confirmNavigationAway.title=Inspector: page navigation
+confirmNavigationAway.message=You are about to leave the current page, losing the current DOM. Are you sure you want to continue?

I might use, "You are about to leave the current location which will close the Inspector, losing any changes you may have made. Are you sure you want to continue?"

In any case, we'll need a ui-review on this.

+confirmNavigationAway.rememberChoice=Remember my choice.

Not sure about this either. Remember my preference? Need ui-review.

Test code looks good, except for the gBrowser.addProgressListener again.
Attachment #461008 - Flags: feedback?(rcampbell) → feedback-
oh, when you accept assignment on a bug, you should change the status to Assigned.
Status: NEW → ASSIGNED
Attached patch updated patch + test code (obsolete) — Splinter Review
Thanks for your feedback, Robert!

I have updated the patch as requested. The gBrowser.addProgressListener() stays in place, as we agreed on IRC. For reference, according to:

https://developer.mozilla.org/en/Code_snippets/Progress_Listeners

... the gBrowser progress events are only triggered for the active tab, which is exactly what we want. This is confirmed by the testing of the fix I did, as well.
Attachment #461008 - Attachment is obsolete: true
Attachment #461286 - Flags: feedback?(rcampbell)
Comment on attachment 461286 [details] [diff] [review]
updated patch + test code

ok, looks good.
Attachment #461286 - Flags: ui-review?(limi)
Attachment #461286 - Flags: review?(gavin.sharp)
Attachment #461286 - Flags: feedback?(rcampbell)
Attachment #461286 - Flags: feedback+
Whiteboard: [strings]
Whiteboard: [strings] → [strings] [kd4b4]
Comment on attachment 461286 [details] [diff] [review]
updated patch + test code

Asking for review from Mossop, as Gavin is leaving really soon on vacation.
Attachment #461286 - Flags: review?(gavin.sharp) → review?(dtownsend)
You should use XPCOMUtils.generateQI rather than rolling your own QI.

The (win != InspectorUI.win) check makes the earlier subframe checks redundant, I think.

I'm not sure I like the idea of calling BrowserStop() from within a WPL callback. It's not immediately obvious that it will always lead to the correct result.

Do we really need a pref for this? I would kind of prefer to just always hide the inspector on navigation...
Gavin: Thanks for your comment! I can switch the code to use generateQI - I only learned of it later - after I wrote this patch.

I agree, the earlier subframe check can be removed. It was used during different iterations of the code, hehe.

Wrt. BrowserStop() ... is there a better way to cancel the page navigation request?

Adding the preference was suggested by Robert. I would like to keep it, because the behavior to always hide the inspector on navigation is really ugly for me as a web developer - I wouldn't like this. (just my suggestion!)
(In reply to comment #15)
> Wrt. BrowserStop() ... is there a better way to cancel the page navigation
> request?

I asked on #developers: call aRequest.cancel(Cr.NS_BINDING_ABORTED);
Prompting+pref just seems like so much extra unneeded overhead. I could live with just the pref, I suppose, but prompting really doesn't feel right.
Attached patch updated patch + test code (obsolete) — Splinter Review
Updated the code as suggested by Gavin. The prompt is still there, I'd like feedback on this from Limi.

Thanks Gavin!
Attachment #461286 - Attachment is obsolete: true
Attachment #463293 - Flags: ui-review?(limi)
Attachment #463293 - Flags: review?(sdwilsh)
Attachment #461286 - Flags: ui-review?(limi)
Attachment #461286 - Flags: review?(dtownsend)
Attached image screenshot of the prompt (obsolete) —
Attaching a screenshot, as requested by Limi.
Comment on attachment 463293 [details] [diff] [review]
updated patch + test code

UI-wise, I think this is fine for a development tool. You probably don't want the inspector to follow you around if you leave the current page, and having the ability to let it not notify you about losing your changes in the future is OK too. 

I assume that if you manually close the inspector, this warning doesn't happen when you navigate away from the page.
Attachment #463293 - Flags: ui-review?(limi) → ui-review+
blocking2.0: ? → betaN+
Comment on attachment 463293 [details] [diff] [review]
updated patch + test code

I'm not a browser peer, so I cannot review this, but dolske can!
Attachment #463293 - Flags: review?(sdwilsh) → review?(dolske)
Limi: that's correct. Once the Inspector is closed, the prompt also stops showing up. Thanks for your ui-review+!
That's not quite the prompt I was expecting. :) I was trying to suggest using one of the sliding prompts like the password change notifications.

http://mxr.mozilla.org/mozilla-central/source/toolkit/content/widgets/notification.xml

see, http://mxr.mozilla.org/mozilla-central/source/toolkit/components/passwordmgr/src/nsLoginManagerPrompter.js#775

for an example.

But, this is definitely a good start.
Comment on attachment 463293 [details] [diff] [review]
updated patch + test code

A few code nits, but I think there's a bigger problem here... These kinds of prompts can be _really_ annoying.  I don't see any kind of dirty-bit setting/checking, so it would seem if someone quicky opens the inspector to examine something, they'll get an annoying prompt when navigating away even though nothing's been changed.

The UI also seems rather unfortunate if you select Cancel + Remember -- forever more, navigating just stops working when the Inspector is open.

I wonder if the prompt should be disabled by default, and have some kind of "lock me on this page" UI menu/checkbox be exposed by the Inspector, so that users doing page modifications can opt-in to stay stuck on the page, but that choice would be temporary to the page/session.

Worth thinking about a way to have the Inspector stay open when navigating, but update it to watch the new page?

>+++ b/browser/app/profile/firefox.js
...
>+// Page navigation behaviour when the Inspector tool is enabled:
>+// 0  ask the user to confirm page navigation.
>+// 1  always allow page navigation.
>+// 2  never allow page navigation.
>+pref("browser.inspector.pageNavigation", 0);

s/behaviour/behavior/ :)


>+++ b/browser/base/content/inspector.js

>+    // Read user pref.
>+    try {
>+      pref = gPrefService.getIntPref("browser.inspector.pageNavigation");
>+    } catch (ex) { }

This patch adds a default to firefox.js, so you can assume it always has a value (no need for try/catch).

>+    if (pref != 0 && pref != 1 && pref != 2) {
>+      pref = 0;
>+    }

< 0 || > 2

>+      let result = Services.prompt.confirmCheck(null, strTitle, strMessage,
>+        strRemember, rememberCheckbox);

Instead of null, the prompt ought to be tied to a specific window when possible.
Attachment #463293 - Flags: review?(dolske) → review-
Dolske: Thanks for your review! You have a good point. One of the ideas I've discussed with Robert would be to switch away from the prompt to a notificationbox. The UI would certainly be nicer *if* I can make it modal (I haven't tried that yet).

However, that would not solve the issue you raised in your comment. It's still annoying, irrespective of the actual way we ask the user to allow page navigation or not.

I really like your idea. I could add a checkbox to the Inspector toolbar "Lock me on this page". Wehn that is enabled, page navigation would be canceled - I think we don't need to use the prompt, because the user explicitly elects to be locked on the page once he enables the given option. This setting would be stored per tab.

Also, regarding the Inspector staying open after page navigation: I am all for that! I suggested this to Robert, but he prefers we close the Inspector.

Robert: what do you think? Should I go for the approach suggested by Dolske with the checkbox? I'd really like that - as a user. :) When page navigation is allowed, should I close the Inspector or update it with the new page? I'd really like, again as a user, the latter behavior.
Whiteboard: [strings] [kd4b4] → [strings] [kd4b5]
I think the addition of an isDirty flag to the inspector code makes a lot of sense. Only prompt the user if they've made changes to the page through the inspector and navigation would cause them to lose those changes.
Robert: I'll add a flag for that then. Thanks! Given that there is no editor at the moment I only add the flag, and in the future it will be set to true. So, basically, the Inspector will just close when the user navigates away - until we have the editors.
Sounds reasonable. We'll use "isDirty" for the property name and you can just check for its truthiness in your code until the editors make use of it.
Attached patch updated patch (obsolete) — Splinter Review
Updated patch, as it was decided: we now use a dirty flag for edits in the Inspector panels. I also made the changes you requested. Thanks!
Attachment #463293 - Attachment is obsolete: true
Attachment #466747 - Flags: review?(dolske)
This is actually a blocker for string freeze, not betaN... re-requesting blocking status.
blocking2.0: betaN+ → ?
Whiteboard: [strings] [kd4b5] → [strings] [kd4b6]
Blocking+, yeah that behavior is pretty broken and b6+ due to strings.
blocking2.0: ? → beta6+
Whiteboard: [strings] [kd4b6] → [strings] [kd4b6] [patchbitrot]
Attached patch Proposed patch. (obsolete) — Splinter Review
Patch rebased to trunk.
Attachment #466747 - Attachment is obsolete: true
Attachment #471203 - Flags: review?(dolske)
Attachment #466747 - Flags: review?(dolske)
Whiteboard: [strings] [kd4b6] [patchbitrot] → [strings] [kd4b6] [patchclean:0901]
Severity: normal → blocker
Inspector feature postponed. Removing blocking flags from Inspector bugs.
blocking2.0: beta6+ → ---
Removing items from kd4b6.
Whiteboard: [strings] [kd4b6] [patchclean:0901] → [strings] [patchclean:0901]
Reprioritizing bugs. You can filter the mail on the word TEABAGS.
Severity: blocker → normal
Comment on attachment 471203 [details] [diff] [review]
Proposed patch.

>+    // Read user pref.
>+    let pref = gPrefService.getIntPref("browser.inspector.pageNavigation");
>+
>+    if (pref < 0 || pref > 2) {
>+      pref = 0;
>+    }
>+
>+    if (!pref) {
>+      // Ask the user what to do with the page navigation request.

Clearer as: if (pref == 0)

>+      pref = result ? 1 : 2;

You're sorta reusing this variable name for both the pref and the user's selected action. If the checkbox (to remember the action) isn't saved, that's a bit confusing.

>+    if (pref == 1) {
>+      // The pref is set to always confirm page navigation.
>+      InspectorUI.closeInspectorUI(true);
>+    } else if (pref == 2) {
>+      // The pref is set to never confirm page navigation.
>+      aRequest.cancel(Components.results.NS_BINDING_ABORTED);
>+    }

Still a concern here -- if the pref gets set to this value, navigation is silently suppressed and the user might be left wondering why their browser is broken. A notification bar (in the browser? in the inspector?) is probably the easiest solution. And if you do that, it could just replace the prompt entirely. Maybe the automatic action isn't even needed, since I assume people won't be randomly editing random pages. Just always show a "Page navigation to etld.site.com canceled, you have unsaved Inspector changes for this page. [Discard and Go Anyway]".

Also, since I didn't actually test this patch, does it correctly handle switching tabs, and navigations triggered in a background tab being Inspected?
Attachment #471203 - Flags: review?(dolske) → review-
Blocks: devtools924
(In reply to comment #36)
> Comment on attachment 471203 [details] [diff] [review]
> Proposed patch.
> 
> >+    // Read user pref.
> >+    let pref = gPrefService.getIntPref("browser.inspector.pageNavigation");
> >+
> >+    if (pref < 0 || pref > 2) {
> >+      pref = 0;
> >+    }
> >+
> >+    if (!pref) {
> >+      // Ask the user what to do with the page navigation request.
> 
> Clearer as: if (pref == 0)
> 
> >+      pref = result ? 1 : 2;
> 
> You're sorta reusing this variable name for both the pref and the user's
> selected action. If the checkbox (to remember the action) isn't saved, that's a
> bit confusing.

Thanks for your review, Justin. Will change these parts.


> >+    if (pref == 1) {
> >+      // The pref is set to always confirm page navigation.
> >+      InspectorUI.closeInspectorUI(true);
> >+    } else if (pref == 2) {
> >+      // The pref is set to never confirm page navigation.
> >+      aRequest.cancel(Components.results.NS_BINDING_ABORTED);
> >+    }
> 
> Still a concern here -- if the pref gets set to this value, navigation is
> silently suppressed and the user might be left wondering why their browser is
> broken. A notification bar (in the browser? in the inspector?) is probably the
> easiest solution. And if you do that, it could just replace the prompt
> entirely. Maybe the automatic action isn't even needed, since I assume people
> won't be randomly editing random pages. Just always show a "Page navigation to
> etld.site.com canceled, you have unsaved Inspector changes for this page.
> [Discard and Go Anyway]".

You're correct, but using a notification like that complicates things:

- if I just always cancel the navigation, and the user selects "go anyway", then? The progress listener and the request are both lost already - I can't "resume" them. The request might be a POST, a GET or anything else.

- if I suspend the request and show the notification box, then sure, we can ask the user, like with the prompt "you have unsaved changes, do you want to continue? [yes] or [no]". This sounds doable, if the request can be nicely suspended indefinitely. I haven't tested.

Thoughts?


> Also, since I didn't actually test this patch, does it correctly handle
> switching tabs, and navigations triggered in a background tab being Inspected?

I have tested it. The current behavior is: the Inspector is open only for the current tab. When the user switches to a different tab, it closes and only saves some state info, and it detaches all event listeners. This means that when the user returns, the Inspector reopens. If the user reloads that tab, or if the page changes location without user interaction, that goes unnoticed, because the Inspector is closed.

Should we change the behavior?
Attached patch notification patch (obsolete) — Splinter Review
This patch includes the changes you have requested, and temporary code that switches to a nicer notification. Thanks again for your review!

I bumped into a blocker. The nsIRequest.suspend() call has no effect, which means I cannot block/suspend the page load, to wait for further user action from the new async notification. Somehow, the prompt did that for me - it blocked the request, waiting for user action.

Currently, any page load is not blocker, the notification only shows and disappears.

According to the API, nsIRequest.suspend() should work:
http://mxr.mozilla.org/mozilla-central/source/netwerk/base/public/nsIRequest.idl#100

still... there's a "catch": "NOTE: some implementations are unable to immediately suspend, and may continue to deliver events already posted to an event queue. In general, callers should be capable of handling events even after suspending a request."

Did I hit that case? If yes, then how can I make sure I "force" a suspend? In the way the prompt service does.

Thanks!
Attachment #475999 - Flags: feedback?(dolske)
dolske: any suggestions on how to proceed with the above? the nsIRequest.suspend() function not working is turning into a bit of a show-stopper for this. With no way to suspend the request, it's not possible to prevent a user's navigation from proceeding.

anyone?
Sorry, missed the comments here in all the bugmail. :/

I'm not sure why .suspend() isn't working, I'm not really familiar with that code. Sounds like a question for biesi or bz?
Thanks, we can ping them with questions.

Also mentioned in IRC, investigate how safebrowsing accomplishes this.
Attached patch Updated patch (obsolete) — Splinter Review
Updated patch. This patch uses a notification bar which allows the user to cancel or confirm page navigation.

As discussed with Robert, I have removed the "Remember my choice" option because it doesn't make sense. I also tested the behavior with multiple tabs and it does what we expect it - the Inspector closes when the user moves to a different tab, which means page navigation is not prevented. Additionally, the progress listener only and always affects the active tab - other tabs/windows where the Inspector is not open are not affected by this change.

The problem I had with nsIRequest.suspend() is no longer "valid". I presume it was a bug in the mozilla-central build I used. Today I pulled from mozilla-central and made new optimized and debug builds. Both work fine.
Attachment #463295 - Attachment is obsolete: true
Attachment #471203 - Attachment is obsolete: true
Attachment #475999 - Attachment is obsolete: true
Attachment #477502 - Flags: review?(dolske)
Attachment #475999 - Flags: feedback?(dolske)
Whiteboard: [strings] [patchclean:0901] → [strings] [patchclean:0922]
Comment on attachment 477502 [details] [diff] [review]
Updated patch

>+    gBrowser.removeProgressListener(InspectorProgressListener);
>+

Hmm, is it possible to get an inspector open for 2 documents? (open tab, inspect, switch tab, inspect)

>+  showNotification: function IPL_showNotification(aRequest)
>+  {
...
>+    if (notification) {
>+      notification.nsIRequest.cancel(Cr.NS_BINDING_ABORTED);
>+      notification.nsIRequest.resume();
>+      notification.nsIRequest = aRequest;
>+      return;
>+    }

Can you just remove the old notification, and continue with adding the new notification? The old notification should clean up after itself.

>+    notification.nsIRequest = aRequest;

It's a bit weird to be using an interface name as a property... Just .request or .linkedRequest? Or hang a .cancelRequest function off it which holds the request via a closure (since the same thing is done in a couple of places)?

>+    notification.addEventListener("DOMNodeRemoved", function(aEvent) {


Sigh. File a followup to add support for a removed() callback? I think the new doorhanger notifications support such a thing. DOM mutation listeners are best to avoid.


>+++ b/browser/locales/en-US/chrome/browser/inspector.properties
...
>+confirmNavigationAway.message=You are about to leave the current location which will close the Inspector, losing any changes you may have made. Are you sure you want to continue?
>+confirmNavigationAway.buttonYes=Yes
>+confirmNavigationAway.buttonYesAccesskey=Y
>+confirmNavigationAway.buttonNo=No
>+confirmNavigationAway.buttonNoAccesskey=N

Yes/No dialogs are generally bad UI. It's better to have the buttons indicate the action that will be performed. The string is also a bit long.

The strings should probably be similar to what was just changed in bug 588292, since they're very similar in purpose.

I'd suggest something like:
.message = Leaving this page will close the Inspector and the changes you have made will be lost.
button1=Leave Page
button2=Stay on Page
Attachment #477502 - Flags: review?(dolske) → review-
(In reply to comment #43)
> Comment on attachment 477502 [details] [diff] [review]
> Updated patch
> 
> >+    gBrowser.removeProgressListener(InspectorProgressListener);
> >+
> 
> Hmm, is it possible to get an inspector open for 2 documents? (open tab,
> inspect, switch tab, inspect)

Yes and no.

Yes, you can open a tab, Inspect, then open a new tab, and Inspect. Then switch back to the first tab to get the Inspect for the first tab. However, the Inspector closes whenever you switch a tab, and reopens if it has remembered a state for the new tab. So, you never get two Inspectors open at the same time, in the same window.

This means that when you switch to a new tab, the progress listener and all events, everything ... from the old tab are removed. Changing this behavior would be beyond the purpose of this patch.


> >+  showNotification: function IPL_showNotification(aRequest)
> >+  {
> ...
> >+    if (notification) {
> >+      notification.nsIRequest.cancel(Cr.NS_BINDING_ABORTED);
> >+      notification.nsIRequest.resume();
> >+      notification.nsIRequest = aRequest;
> >+      return;
> >+    }
> 
> Can you just remove the old notification, and continue with adding the new
> notification? The old notification should clean up after itself.

Yeah, I think that's possible, but I did not do this for a few reasons:

- there's no point in animating a slide out and then back a slide-in ... with identical question and options.

- having read other code through Firefox ... I saw the same approach: reuse the same notification. This is why getNotificationWithValue() is there (iianm).

- the lack of an elegant callback for when the notification is removed. (see the DOMNodeRemoved event handler).

Nonetheless, if you want, I can change the code. Please let me know.


> >+    notification.nsIRequest = aRequest;
> 
> It's a bit weird to be using an interface name as a property... Just .request
> or .linkedRequest? Or hang a .cancelRequest function off it which holds the
> request via a closure (since the same thing is done in a couple of places)?

Agreed. Will look into fixing this.


> >+    notification.addEventListener("DOMNodeRemoved", function(aEvent) {
> 
> Sigh. File a followup to add support for a removed() callback? I think the new
> doorhanger notifications support such a thing. DOM mutation listeners are best
> to avoid.

I was also surprised to see the lack of a removed() callback. Where shall I file the bug? Which component?


> >+++ b/browser/locales/en-US/chrome/browser/inspector.properties
> ...
> >+confirmNavigationAway.message=You are about to leave the current location which will close the Inspector, losing any changes you may have made. Are you sure you want to continue?
> >+confirmNavigationAway.buttonYes=Yes
> >+confirmNavigationAway.buttonYesAccesskey=Y
> >+confirmNavigationAway.buttonNo=No
> >+confirmNavigationAway.buttonNoAccesskey=N
> 
> Yes/No dialogs are generally bad UI. It's better to have the buttons indicate
> the action that will be performed. The string is also a bit long.
> 
> The strings should probably be similar to what was just changed in bug 588292,
> since they're very similar in purpose.
> 
> I'd suggest something like:
> .message = Leaving this page will close the Inspector and the changes you have
> made will be lost.
> button1=Leave Page
> button2=Stay on Page

Will change the strings.

Thanks for your review!
Attached patch updated patch (obsolete) — Splinter Review
Updated patch based on review.

Changes:

- no longer using notification.nsIRequest, nor any other property to link back to the nsIRequest object. Callbacks use the aRequest variable from the scope.

- filed bug 600501 about notification removed() callback. (found where to do it)

- updated the strings as suggested. It looks much clearer now.

Thanks!
Attachment #477502 - Attachment is obsolete: true
Attachment #479347 - Flags: review?(dolske)
Whiteboard: [strings] [patchclean:0922] → [strings] [patchclean:0929]
No longer blocks: devtools924
Comment on attachment 479347 [details] [diff] [review]
updated patch

AIUI this code isn't enabled in FF4 any more, so clearing review. Reflag when we start working on post-FF4 things.
Attachment #479347 - Flags: review?(dolske)
Attached patch new patch (obsolete) — Splinter Review
Updated/rebased patch on top of the latest Inspector code.

- made some minor code quality improvements (hey, learned some stuff since last autumn!).
- some minor test improvements.

Please let me know if this patch needs further changes. Thank you!


(Note that the UI and behavior was decided quite some time ago. Please read the comments above. If you want changes, I can do that, of course.)
Attachment #479347 - Attachment is obsolete: true
Attachment #543909 - Flags: review?(rcampbell)
Whiteboard: [strings] [patchclean:0929] → [strings]
Comment on attachment 543909 [details] [diff] [review]
new patch

nit:

+  onStateChange:
+  function IPL_onStateChange(aProgress, aRequest, aFlag, aStatus) {
+    // Remove myself if the Inspector is no longer open.

Brace on next line for functions! (file-consistency)

+    notification = notificationBox.appendNotification(message,
+      "inspector-page-navigation", "chrome://browser/skin/Info.png",
+      notificationBox.PRIORITY_WARNING_HIGH, buttons);
+
+    notification.persistence = 10;

bit of a magic number. Why 10? This should probably be a const.

+++ b/browser/base/content/test/inspector/browser_inspector_bug_566084_location_changed.js

+
+  gBrowser.addProgressListener(TestProgressListener1);

not sure we want to use a progress listener for this test.

+  onLocationChange: function TPL1_onLocationChange(aProgress, aRequest, aURI) {
+    gBrowser.removeProgressListener(TestProgressListener1);
+    ok(false, "navigation was not cancelled");
+    testEnd();
+  },

definitely don't like this.

Why not check for the existence of the notificationBox? You can listen for AlertActive and do away with this progress listener.

Otherwise, I like the addition of the notificationbox. This should look good when it's ready.

r- for the magic number and test implementation, but it's close.
Attachment #543909 - Flags: review?(rcampbell) → review-
Whiteboard: [strings] → [strings][minotaur]
Attached patch new patch 2 (obsolete) — Splinter Review
Updated the patch to address the review comments.

Thank you!
Attachment #543909 - Attachment is obsolete: true
Attachment #546829 - Flags: review?(rcampbell)
Comment on attachment 546829 [details] [diff] [review]
new patch 2

I don't like having different success/fail conditions inside if statements.

+function onPageLoad() {
+  if (content.location.href.indexOf("test1") > -1) {
+    ok(false, "page navigation was not canceled");
+  } else if (content.location.href.indexOf("test2") > -1) {
+    gBrowser.selectedBrowser.removeEventListener("load", onPageLoad, true);
+    ok(true, "page navigation was allowed");
+

Couldn't we do away with the if() test and do:

ok(content.location.href.indexOf("test2") > -1, "page navigation allowed");

Then the rest of the tests get run and pass or fail. The if seems unnecessary.

(do we get a load event when the progressListener is canceled? That seems surprising)

r+ with the above tweak.
Attachment #546829 - Flags: review?(rcampbell) → review+
(In reply to comment #51)
> Comment on attachment 546829 [details] [diff] [review] [review]
> new patch 2
> 
> I don't like having different success/fail conditions inside if statements.
> 
> +function onPageLoad() {
> +  if (content.location.href.indexOf("test1") > -1) {
> +    ok(false, "page navigation was not canceled");
> +  } else if (content.location.href.indexOf("test2") > -1) {
> +    gBrowser.selectedBrowser.removeEventListener("load", onPageLoad, true);
> +    ok(true, "page navigation was allowed");
> +
> 
> Couldn't we do away with the if() test and do:
> 
> ok(content.location.href.indexOf("test2") > -1, "page navigation allowed");
> 
> Then the rest of the tests get run and pass or fail. The if seems
> unnecessary.

Good point.
Attached patch new patch 3 (obsolete) — Splinter Review
Test tweaked.

Pushed to the try server:

http://tbpl.mozilla.org/?tree=Try&rev=cb21ca1e2e7e
Attachment #546829 - Attachment is obsolete: true
Results are green. This patch can land in fx-team.
Whiteboard: [strings][minotaur] → [strings][minotaur][land-in-fx-team]
Comment on attachment 546853 [details] [diff] [review]
new patch 3

Asking for review from a browser peer.
Attachment #546853 - Flags: review?(dolske)
Whiteboard: [strings][minotaur][land-in-fx-team] → [strings][minotaur]
It looks like is isDirty is never set to true in that patch (apart from in the test). Is that intentional?
(In reply to comment #56)
> It looks like is isDirty is never set to true in that patch (apart from in
> the test). Is that intentional?

Yes. Once editing capabilities are implemented, isDirty will be set to true, and users will be asked to confirm they want to lose changes they made. Otherwise page navigation is not canceled. (as was decided)
Priority: -- → P1
Whiteboard: [strings][minotaur] → [strings][minotaur][has-patch]
Comment on attachment 546853 [details] [diff] [review]
new patch 3

I started thinking "hmm, maybe this should be a doorhanger now"... And then thought "self, how about we land this damn thing first, and iterate on it later."
Attachment #546853 - Flags: review?(dolske) → review+
(In reply to Justin Dolske [:Dolske] from comment #59)
> Comment on attachment 546853 [details] [diff] [review]
> new patch 3
> 
> I started thinking "hmm, maybe this should be a doorhanger now"... And then
> thought "self, how about we land this damn thing first, and iterate on it
> later."

I think you should listen to that fellow. He has good ideas.

Personally, I like the notification box, but would not mind a doorhanger. Where would we attach it? The location bar? The originating link?

Let's land this puppy!
Whiteboard: [strings][minotaur][has-patch] → [strings][minotaur][has-patch][reviewed][needs-rebase][can-land]
Attached patch [in-fx-team] rebased patch (obsolete) — Splinter Review
Rebased the patch.
Attachment #546853 - Attachment is obsolete: true
Comment on attachment 553210 [details] [diff] [review]
[in-fx-team] rebased patch

Landed:
http://hg.mozilla.org/integration/fx-team/rev/7715bba5cc3a

Dolske: thanks for the review+!
Attachment #553210 - Attachment description: rebased patch → [in-fx-team] rebased patch
Whiteboard: [strings][minotaur][has-patch][reviewed][needs-rebase][can-land] → [strings][minotaur][fixed-in-fx-team]
Comment on attachment 553210 [details] [diff] [review]
[in-fx-team] rebased patch

>+    gBrowser.addProgressListener(InspectorProgressListener);

>+/**
>+ * The InspectorProgressListener object is an nsIWebProgressListener which
>+ * handles onStateChange events for the inspected browser. If the user makes
>+ * changes to the web page and he tries to navigate away, he is prompted to
>+ * confirm page navigation, such that he's given the chance to prevent the loss
>+ * of edits.
>+ */
>+var InspectorProgressListener = {
>+  QueryInterface: XPCOMUtils.generateQI([Ci.nsIWebProgressListener]),

There is no XPCOM involved for progress listeners added via gBrowser.addProgressListener. Nothing expects this object to implement nsIWebProgressListener.

>+  onLocationChange: function() {},
>+  onProgressChange: function() {},
>+  onStatusChange: function() {},
>+  onSecurityChange: function() {},

And these can be dropped.
Comment on attachment 553210 [details] [diff] [review]
[in-fx-team] rebased patch

>+++ b/browser/base/content/inspector.js

>+    // We need a removed() callback for notifications. See bug 600501.
>+    notification.addEventListener("DOMNodeRemoved",

Erm, I think this would be a blocker for this to land on mozilla-central. Adding a single mutation event listener still slows down all DOM mutations in that window even after you've removed it again. You're in the browser window here, so this isn't acceptable.
Attachment #553210 - Flags: review-
-> backed out
Whiteboard: [strings][minotaur][fixed-in-fx-team] → [strings][minotaur]
(In reply to Dão Gottwald [:dao] from comment #65)
> -> backed out

Thanks for your review comments! Good catches. We'll update the patch as needed. We'll go for fixing bug 600501.

I was about to backout this patch and I saw you already did. Thanks!
Depends on: 600501
yes. Thanks for the quick catch and backout, Dao!
Summary: Inspect gets disabled when navigating to new pages → Inspect should be disabled when navigating to new pages
Summary: Inspect should be disabled when navigating to new pages → Highlighter should be disabled when navigating to new pages
Updated the patch to address Dão's comments, and rebased on top of the patch submitted for bug 600501. Changes:

- updated the InspectorProgressListener as suggested.
- no longer using the DOM mutation event listener. using the new removed event callback from bug 600501.

Please let me know if this patch needs further changes. Thank you!
Attachment #553210 - Attachment is obsolete: true
Attachment #555182 - Flags: review?(dao)
Pushed this patch and the new patch from bug 600501:

http://tbpl.allizom.org/?tree=Try&usebuildbot=1&rev=117225c63f43

Green results!
Comment on attachment 555182 [details] [diff] [review]
[checked-in] address dão's comments

r=me on the interdiff
Attachment #555182 - Flags: review?(dao) → review+
(In reply to Dão Gottwald [:dao] from comment #70)
> Comment on attachment 555182 [details] [diff] [review]
> address dão's comments
> 
> r=me on the interdiff

Thank you Dão!
Whiteboard: [strings][minotaur] → [strings][minotaur][land-in-fx-team]
Comment on attachment 555182 [details] [diff] [review]
[checked-in] address dão's comments

Landed:
http://hg.mozilla.org/integration/fx-team/rev/6f44a95fa1f5
Attachment #555182 - Attachment description: address dão's comments → [in-fx-team] address dão's comments
Whiteboard: [strings][minotaur][land-in-fx-team] → [strings][minotaur][fixed-in-fx-team]
Comment on attachment 555182 [details] [diff] [review]
[checked-in] address dão's comments

http://hg.mozilla.org/mozilla-central/rev/6f44a95fa1f5
Attachment #555182 - Attachment description: [in-fx-team] address dão's comments → [checked-in] address dão's comments
Status: ASSIGNED → RESOLVED
Closed: 13 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 9
Whiteboard: [strings][minotaur][fixed-in-fx-team] → [strings][minotaur][fixed-in-fx-team][qa+]
Verified fixed using Mozilla/5.0 (Windows NT 6.1; rv:10.0a1) Gecko/20111006 Firefox/10.0a1
Status: RESOLVED → VERIFIED
Given that this has been set for milestone=Firefox9 and verified fixed on Firefox 10, I'm asking for tracking/status.

I'm guessing this status-firefox10:fixed and status-firefox9:affected?
Target milestone = Firefox 9 means that this was fixed when Firefox 9 was on mozilla-central. Since mozilla-central later became the starting point for Firefox 10 (and Firefox 11 now), it contains this patch as well as any future release. This is true for all patches landing on mozilla-central. status-firefoxXX flags need to be set for branch landings. Last but not least, tracking request are something entirely different and not needed in this case...
Thanks Dao.

Teodosia, please verify if this is fixed on Firefox 9. Thanks.
Product: Firefox → DevTools
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: