Closed Bug 661884 Opened 13 years ago Closed 12 years ago

Selection events occur only after (successful!) page load

Categories

(Add-on SDK Graveyard :: General, defect, P1)

x86
Linux
defect

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: tlainson, Assigned: zer0)

References

Details

User-Agent:       Mozilla/5.0 (X11; Linux i686; rv:2.0) Gecko/20110321 Firefox/4.0
Build Identifier: Addon SDK 1.0rc1, Mozilla/5.0 (X11; Linux i686; rv:2.0) Gecko/20110321 Firefox/4.0

As far as I can tell:
Selection events aren't fired while the page is still loading (minor annoyance).  If the pageload is cancelled by the user, the addon will never receive selection events for that page (more serious).

In both cases, selection.text and selection.html return the correct values.  We're just not informed that they've changed.

Reproducible: Always

Steps to Reproduce:
1. require("selection").on('select', function() console.log('boo!'));
2. Visit a slow website.
3. Select some text while the page is still loading.
4. Press <Escape> while the page is still loading, then select some other text.

Actual Results:  
No output.

Expected Results:  
"boo!" printed twice.
This might require a platform change to fix; I think we wait until the page is loaded to start listening for selections because the API we're using requires it.
Priority: -- → P2
Target Milestone: --- → Future
See Also: → 664988
Matteo, do you have any insight into whether we need a platform change or if this is something we can do ourselves?
Whiteboard: [triage:followup]
(Pushing all open bugs to the --- milestone for the new triage system)
Target Milestone: Future → ---
Still waiting for input from Matteo.
Assignee: nobody → zer0
Priority: P2 → --
Depends on: 751469
I will check again this bug after I fixed the bug 751469. However I'm quite confident that Myk is right.
In `selection.js` we're using the `Tracker` exposed by `tab-browser` module, so we have the load event only when the page is actually fully loaded.
Maybe we can fix it using the observer topic "document-element-inserted" instead; adding listeners at that point seems works.
We have just to be sure that we limit that behavior to the document loaded in tabs, and figure out in which event doing the clean up.
Status: UNCONFIRMED → NEW
Ever confirmed: true
Depends on: 803027
Status: NEW → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.