Closed Bug 419190 Opened 16 years ago Closed 8 years ago

instance() function not behaving as expected in official Test Suite

Categories

(Core Graveyard :: XForms, defect)

x86
Windows XP
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED WONTFIX

People

(Reporter: koen.heene, Unassigned)

References

()

Details

Attachments

(2 files)

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.12) Gecko/20080201 Firefox/2.0.0.12
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.12) Gecko/20080201 Firefox/2.0.0.12

Hello,

The Mozilla XForms status page
(http://www.mozilla.org/projects/xforms/status-detail.html) states
that the function instance() is supported.

If had difficulties getting that to work. I went to the official
XForms test site and saw that the output is not as predicted by the test suite and also not as you would expect after having read the specs.

I currently work with FireFox 2.0.0.12 and the XForms extension 0.8.4.

Thank you for looking into this.

--
Koen

Reproducible: Always

Steps to Reproduce:
1. go to the URL above

Actual Results:  
The output of <xforms:output/> is not as predicted

Expected Results:  
That is described on the same test page.
The official w3.org test page has given the id="defaultInstance" to the instance they want to retrieve with instance() or instance(''). I don't find this possibility in the specs and therefore consider the Test Page erroneous.

The example in the attachment tries to correct that, but shows that the problems persists.
Noteworthy in the attachment is the fact that the 2nd <xforms:output/> shows the label, but not the value. So it seems that instance() effectively retrieves the anonymous instance, but not the value identified by the XPath.
Thanks for the bug.  We do not correctly handle instance() with no parameter or empty string parameter.
Thank you for replying.

Would it be useful to mention on the Mozilla XForms status page that instance() is only partly supported?

I suppose that the status page is a very important reference for developers.

Thank you,
Koen
updated the status page to include this bug
Status: UNCONFIRMED → NEW
Ever confirmed: true
Blocks: 326372
Attached patch patch for 1.8Splinter Review
This fix is for the 1.8 branch.  The trunk will have to do something similar, but it also needs to overcome the fact that xpath extension functions aren't allowed to have optional parameters, yet.
Attachment #305630 - Flags: review?(Olli.Pettay)
Attachment #305630 - Flags: review?(surkov.alexander)
Comment on attachment 305630 [details] [diff] [review]
patch for 1.8


>+          rv = document->GetElementById(instanceId, getter_AddRefs(instEle));
>+        }
>+      } else {
>+        instanceId = EmptyString();
>+        useDefaultInst = PR_TRUE;
>+      }
>  
>       PRBool foundInstance = PR_FALSE;
>       nsAutoString localname, namespaceURI;
>       if (instEle) {
>         instEle->GetLocalName(localname);
>         instEle->GetNamespaceURI(namespaceURI);
>         if (localname.EqualsLiteral("instance") && 
>             namespaceURI.EqualsLiteral(NS_NAMESPACE_XFORMS)) {
>           foundInstance = PR_TRUE;
>         }
>       }

this one and

>-      if (!foundInstance) {
>+
>+      // if we were given an instance id and couldn't find it, then bow out
>+      if (!foundInstance && !useDefaultInst) {
>         // We didn't find an instance element with the given id.  Return the
>         //   empty result set.
>         *aResult = resultSet;
>         NS_ADDREF(*aResult);


this one may be moved after rv = document->GetElementById(instanceId, getter_AddRefs(instEle)), right?

>+      if (!useDefaultInst) {
>+        instNode = do_QueryInterface(instEle);
>+        rv = xformsService->GetModelFromNode(instNode, 
>+                                             getter_AddRefs(modelInstance)); 
>+                                   
>+        NS_ENSURE_SUCCESS(rv, rv);
>+   
>+        rv = xformsService->IsNodeAssocWithModel(xfContextNode, 
>+                                                 modelInstance, 
>+                                                 &modelContainsNode);
>+        NS_ENSURE_SUCCESS(rv, rv);

why can't you have common algorithm here? It sounds "else" case is suitable for the "if" case?

>+      } else {
>+        // xforms stores the instance element that was used to create the
>+        // standalone instance document as a property of that document
>+        nsCOMPtr<nsIDOMDocument> instanceDOMDoc;
>+        xfContextNode->GetOwnerDocument(getter_AddRefs(instanceDOMDoc));

please check this, iirc document->GetOwnerDocument should return document.

with comments addressed r=me
Attachment #305630 - Flags: review?(surkov.alexander) → review+
> >+      } else {
> >+        // xforms stores the instance element that was used to create the
> >+        // standalone instance document as a property of that document
> >+        nsCOMPtr<nsIDOMDocument> instanceDOMDoc;
> >+        xfContextNode->GetOwnerDocument(getter_AddRefs(instanceDOMDoc));
> 
> please check this, iirc document->GetOwnerDocument should return document.
Nope. That returns null. http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html#node-ownerDoc

(in gecko we have nsINode::GetOwnerDoc() which always returns the owner document)

Attachment #305630 - Flags: review?(Olli.Pettay) → review+
(In reply to comment #8)
> > >+      } else {
> > >+        // xforms stores the instance element that was used to create the
> > >+        // standalone instance document as a property of that document
> > >+        nsCOMPtr<nsIDOMDocument> instanceDOMDoc;
> > >+        xfContextNode->GetOwnerDocument(getter_AddRefs(instanceDOMDoc));
> > 
> > please check this, iirc document->GetOwnerDocument should return document.
> Nope. That returns null.
> http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html#node-ownerDoc
> 
> (in gecko we have nsINode::GetOwnerDoc() which always returns the owner
> document)
> 

Thank you. Then I messed them :)
RIP xforms
Status: NEW → RESOLVED
Closed: 8 years ago
Resolution: --- → WONTFIX
Product: Core → Core Graveyard
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: