Closed Bug 721849 Opened 12 years ago Closed 12 years ago

add-on SDK context menu items missing depending on navigation history

Categories

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

x86_64
Windows 7
defect

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: karlden, Assigned: mossop)

References

Details

(Whiteboard: [jpcontextmenu])

Attachments

(1 file)

User Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.7 (KHTML, like Gecko) Chrome/16.0.912.75 Safari/535.7

Steps to reproduce:

First I copied the directory "TestAddonMenu" to c:\. It has two simple scriptless html test files. (files are in attachment)

As described on the mozilla add-on web page https://addons.mozilla.org/en-US/developers/docs/sdk/1.4/dev-guide/addon-development/implementing-simple-addon.html, I created the sample wikipanel add-on. First I created a "wikipanel" directory, then at the command line ran "cfx init". As described on that page, using code provided there and copied here, I then replaced the contents of main.js with:

-----------------------
// Import the APIs we need.
var contextMenu = require("context-menu");
var panel = require("panel");
 
exports.main = function(options, callbacks) {
  console.log(options.loadReason);
 
  // Create a new context menu item.
  var menuItem = contextMenu.Item({
    label: "What's this?",
    // Show this item when a selection exists.
    context: contextMenu.SelectionContext(),
    // When this item is clicked, post a message back with the selection
    contentScript: 'self.on("click", function () {' +
                   '  var text = window.getSelection().toString();' +
                   '  self.postMessage(text);' +
                   '});',
    // When we receive a message, look up the item
    onMessage: function (item) {
      console.log('looking up "' + item + '"');
      lookup(item);
    }
  });
};
 
function lookup(item) {
  wikipanel = panel.Panel({
    width: 240,
    height: 320,
    contentURL: "http://en.wikipedia.org/w/index.php?title=" +
                item + "&useformat=mobile"
  });
  wikipanel.show();
}
-----------------------

Then from the command line I executed "cfx run", twice as required to get an identifier. 

The firefox browser came up. I then entered "file:///C:/TestAddonMenu/TestBegin.html" to open a simple html test file (attached), which had been copied with its companion file and folder "c:\testAddonMenu". I then followed the instructions in that file and its companion file, which are named TestBegin.html and TestSecond.html. I then created the wikipanel.xpi file using the command "cfx xpi", again as described in the SDK instructions.

I installed the add-on in firefox 9.0.1, and repeated the procedure by opening the first test file and following its instructions. Both tests gave the same results. The two test html files, when formatted by the browser, read as follows:

First local test html File

Step 1: Select a word in this text to create the selection context, right click the selection or anywhere on the page to bring up the context menu. You should see a "What's this?" menu item at the bottom. If you do see the item then go to step 2. If you do not see the item then the add-on is likely not properly set-up.

Step 2: Click on the following link and follow the instructions there-- Go to Second html File


Second local test html File

Step 3: Select a word from this text, bring up the context menu by right clicking on this page. If the context menu does not have the expected "What's this?" menu item, then you have reproduced the bug. A more complicated reproduction using a public web page may be possible by continuing at step 4.

 This issue occurs whether or not XUL cache is enabled.


ADDITIONAL REPRO PROCEDURE

Step 4: Perform the remaining instructions using public web pages (that will change over time): start by following the link: Go to Web 101 Links

Step 5: Verify that the "What's this?" context menu item appears on that page, it should be there (even though a new tab was created, see below for non-reproductions of this bug).

Step 6: On that page, click on the second "HTMLGoodies" link, which should open a new tab. If it does not open a new tab then you clicked the wrong link or the page has changed.

Step 7: On the newly opened tab from step 6, make a selection and bring up the context menu by right clicking. If you do not see the expected "What's this?" menu item, then you have reproduced the bug.

 

NON REPRODUCING PROCEDURE (for my machine)

NOTE: While all known reproductions of this bug require following a link that opens a new tab, and each such link has the attribute "target=_blank", as seen within the reproduction procedure this is by itself insufficient to guarantee reproduction of the bug. While on my machine reproducing the bug is 100% reliable by the foregoing procedures, on my machine I get 0% reproduction of this bug by doing the following.

Step 1: Follow the link: Go to a Mozilla https site having a link with the "target=_blank" attribute

Step 2: Verify that the "What's this?" context menu item appears on that page, it should appear if it works as it does on my machine. This in itself could be considered a non-repro of the bug. Nevertheless, continue.

Step 3: On the left column of that page, click on the "volunteer opportunities" link, which should open a new tab. If it does not open a new tab then you clicked the wrong link or the page has changed.

Step 4: On the newly opened tab from step 3, make a selection and bring up the context menu by right clicking. On my machine the "What's this?" menu item always appears which is another non-repro of the bug (it is as should be expected except for the bug).


Actual results:

The "What's this?" menu item does not appear under certain test circumstances even when there is a selection.

SOME DETAILS

Perhaps worth mentioning is a correlation (although a small sample) that I have noticed; so far, when the "What's this?" menu item does not appear as expected, the URI of the new tab where it fails has the same host address as the page from which it was launched. However, the lack of a DNS lookup, even as only a timing issue, appears unlikely to be relevant since such addresses are cached and the failures can be (again on my machine) repeated any number of times with the same outcome. In the mozilla non-repeat example, the first host is "donate.mozilla.org", which today resolved to 64.94.250.109, and the target host is "www.mozilla.org", which today resolved to 63.245.209.11. Again, this is a small sample correlation.<\p>

In these tests it is useful to be sure about the appearance of the add-on menu item by bringing up the menu a few times, because the add-on menu item can be temporarily absent for some time after a web page first appears. This slowness occurs even if the menu item has appeared previously in a different browser window. It may be so slow to appear that a user can repeatedly, although only temporarily, open the context menu without the expected add-on menu item appearing. However, slowness of the browser to get add-on context menu items correct before a user can bring it up is likely a separate issue because this failure is not temporary.<\p>


Expected results:

The "What's this?" menu item should appear every time there is a selection and the context menu is brought up, but it does not do so under the test circumstances described.
Attachment #592250 - Attachment mime type: text/plain → application/zip
Component: Untriaged → General
Product: Firefox → Add-on SDK
QA Contact: untriaged → general
Version: 9 Branch → unspecified
Matteo, can you take a look at this?
Assignee: nobody → zer0
Whiteboard: [triage:followup]
It's definitely a bug, I was able to reproduce this bug. It's not limited to selection context (can be applied on different `context` as well).

The context menu module is one of the oldest modules (and messier as well), I need more time to go in a deeper investigation and understand why we have this behavior. On first sight, I believe is related to some document's event that is not properly dispatched so the menu item is not added.
Status: UNCONFIRMED → NEW
Ever confirmed: true
Priority: -- → P1
Whiteboard: [triage:followup]
Whiteboard: [jpcontextmenu]
I'm not able to reproduce this bug anymore (Firefox 14.0.1, latest Add-on SDK, master). Not sure what is changed, I'm not aware of any change on `context-menu` module.

Could anyone confirm that this bug is gone, and it's not just me? :)
Depends on: 788324
I can still reproduce this but I can also see that it's fixed by my work in bug 788324.
Assignee: zer0 → dtownsend+bugmail
Status: NEW → ASSIGNED
Fixed by bug 788324
Status: ASSIGNED → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
Target Milestone: --- → 1.13
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: