Closed Bug 610676 Opened 14 years ago Closed 9 years ago

Build from ad0a0be8be74 has broken Selenium .submit function

Categories

(Core :: JavaScript Engine, defect)

x86
macOS
defect
Not set
normal

Tracking

()

RESOLVED WONTFIX

People

(Reporter: automatedtester, Unassigned)

Details

(Keywords: regression)

Attachments

(2 files, 1 obsolete file)

Attached file Selenium IDE
In nightly from http://ftp.mozilla.org/pub/mozilla.org/firefox/nightly/2010/10/2010-10-14-03-mozilla-central/ the .submit(formElement) in Selenium started throwing errors when the command was executed.

The error is

    [info] Executing: |submit | myForm | |
    [error] Unexpected Exception: QueryInterface -> function QueryInterface() { [native code] }, message -> Component is not available, result -> 2147746065, name -> NS_ERROR_NOT_AVAILABLE, filename -> chrome://selenium-ide/content/selenium/scripts/selenium-browserbot.js, lineNumber -> 1656, columnNumber -> 0, location -> JS frame :: chrome://selenium-ide/content/selenium/scripts/selenium-browserbot.js :: anonymous :: line 1656, inner -> null, data -> null, initialize -> function initialize() { [native code] }


The lines that it is talking about is 

BrowserBot.prototype.submit = function(formElement) {
    var actuallySubmit = true;
    this._modifyElementTarget(formElement);
    if (formElement.onsubmit) {

The formElement is created in Selenium by specifying the target in Selenium IDE which is attached. There is a test case attached for Selenium IDE that will recreate the issue.
Attached file Selenium Test Case to reproduce (obsolete) —
Assignee: nobody → general
Component: General → JavaScript Engine
Product: Firefox → Core
QA Contact: general → general
I took a guess about the component where this should go, at least to get it triaged.
Can you please post the pushlog with the changeset ids so we can see which check-ins happened during this day? Thanks.
Which of the lines in comment 0 is the exception being thrown on?

And is this code running as chrome, or in a web page?
Pushlog is

http://hg.mozilla.org/mozilla-central/pushloghtml?fromchange=2593c8c8af8b&tochange=ad0a0be8be74


This is running in the chrome.

The line that it throws the error on is

if (formElement.onsubmit){
I will try to find the causing check-in by running a hg bisect through the day.
This should never have worked; see bug 607352.  Why were you not getting an XPCNativeWrapper before but are getting one now?

The relevant changeset will be something from the compartments landing; stuff inside there may or may not actually compile.
It appears as thought it is now returning a XPCNativeWrapper like mentioned by
Boris in comment #7.

Updating the Selenium code to 

BrowserBot.prototype.submit = function(formElement) {
    var actuallySubmit = true;
    if (formElement.wrappedJSObject){
        formElement = formElement.wrappedJSObject;
    }
    this._modifyElementTarget(formElement);
    if (formElement.onsubmit) {

doesn't throw the error any more.
OK, and it wasn't before?  Where's formElement coming from?

(As a note, the code in comment 8 is the wrong way to unwrap an XPCNativeWrapper, but let's not worry about that for now.)
so the testrunner calls in selenium-api.js

Selenium.prototype.doSubmit = function(formLocator) {
    /**
   * Submit the specified form. This is particularly useful for forms without
   * submit buttons, e.g. single-input "Search" forms.
   *
   * @param formLocator an <a href="#locators">element locator</a> for the form you want to submit
   */
    var form = this.browserbot.findElement(formLocator);
    return this.browserbot.submit(form);

};

where form locator is xpath=//form in the test case. Then it calls the below code in selenium-browserbot.js

BrowserBot.prototype.submit = function(formElement) {
    var actuallySubmit = true;
    if (formElement.wrappedJSObject){
        formElement = formElement.wrappedJSObject;
    }
    this._modifyElementTarget(formElement);
    if (formElement.onsubmit) {
    .....

which then executes.

This code is is viewable at http://code.google.com/p/selenium/source/browse/#svn/trunk/ide/src/extension/content
OK, what does that findElement function do?  (I did search for it using your link, but there are tons of irrelevant hits.)
findElement is in selenium-browserbot.js. vim has it as line number 1416. Most of the Selenium core code is in this file
OK, that ends up indirecting through:

  var locatorFunction = this.locationStrategies[locatorType];
  locatorFunction.call(this, locator, inDocument, inWindow)

What does that actually call in this case?
in this case its going down to the xpath code

/**
 * Finds an element identified by the xpath expression. Expressions _must_
 * begin with "//".
 */
BrowserBot.prototype.locateElementByXPath = function(xpath, inDocument, inWindow) {
    return this.xpathEvaluator.selectSingleNode(inDocument, xpath, null,
        this._namespaceResolver);
};

BrowserBot.prototype._namespaceResolver = function(prefix) {
    if (prefix == 'html' || prefix == 'xhtml' || prefix == 'x') {
        return 'http://www.w3.org/1999/xhtml';
    } else if (prefix == 'mathml') {
        return 'http://www.w3.org/1998/Math/MathML';
    } else {
        throw new Error("Unknown namespace: " + prefix + ".");
    }
};
OK, which of the 4 different implementations of selectSingleNode (none of which take the namespace resolved as the 4th argument) is involved?

But at this point, the only real options are either that we had a bug before and handed out something that wasn't XPCNativeWrapper when we shouldn't have or that something weird is going on...
(In reply to comment #5)
> http://hg.mozilla.org/mozilla-central/pushloghtml?fromchange=2593c8c8af8b&tochange=ad0a0be8be74

I should have been checked that before I have started the bisect this morning. As it turns out this range is not correct for my self-made opt build. I will continue tomorrow.
For me this failure appeared the first time with the 10071603 build. So one of the following changes has been caused it on my box:

http://hg.mozilla.org/mozilla-central/pushloghtml?fromchange=5fda39cd703c&tochange=96de199027d7
That's a lot less believable than the first regression range; nothing in this new range looks relevant.
So I did a bisect given my pushlog from above and I can clearly reproduce it with the revision below. Everything is fine without this patch.

The first bad revision is:
changeset:   47784:aba8cc27fcef
parent:      47782:b141a304ad08
parent:      47783:d4aafb90ff96
user:        Jim Mathies <jmathies@mozilla.com>
date:        Thu Jul 15 21:47:52 2010 -0500
summary:     merge

This merge is related to:
http://hg.mozilla.org/mozilla-central/rev/d4aafb90ff96	Jim Mathies — Backing out 'Call Show if our nsIXULWindow will not' patch from bug 574690 due to various regressions. r=bz
Made a minor adjustment to the test case to help
Attachment #489178 - Attachment is obsolete: true
David, were you able to get closer to the new range you have mentioned on IRC last Friday?
I think that I was doing something wrong because I was able to replicate the issue in the clean profile using the add-on going back into the June nightlies however if I use Firefox 4b6 build 2 using Selenium RC I don't get an error. If I use Firefox 4b7 build 1 I get the error.

from selenium import selenium
sel = selenium('localhost', 4444, '*firefox', 'http://crash-stats.stage.mozilla.com')
sel.start()
sel.open('/')
sel.submit('//form')
I wonder if we should stick by the extension first and not jump between both ways of running tests.
Assignee: general → nobody
Anything actionable here at this point?
Flags: needinfo?(dburns)
that API is now deprecated in selenium so closing
Status: NEW → RESOLVED
Closed: 9 years ago
Flags: needinfo?(dburns)
Resolution: --- → WONTFIX
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: