~ubuntu-branches/ubuntu/saucy/mozjs17/saucy-proposed

« back to all changes in this revision

Viewing changes to js/src/tests/e4x/XML/13.4.4.10.js

  • Committer: Package Import Robot
  • Author(s): Rico Tzschichholz
  • Date: 2013-05-25 12:24:23 UTC
  • Revision ID: package-import@ubuntu.com-20130525122423-zmxucrhtensw90xy
Tags: upstream-17.0.0
ImportĀ upstreamĀ versionĀ 17.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// |reftest| pref(javascript.options.xml.content,true)
 
2
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
 
3
 *
 
4
 * This Source Code Form is subject to the terms of the Mozilla Public
 
5
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 
6
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
7
 
 
8
 
 
9
var nTest = 0;
 
10
 
 
11
START("13.4.4.10 - XML contains()");
 
12
 
 
13
TEST(++nTest, true, XML.prototype.hasOwnProperty("contains"));
 
14
 
 
15
emps =
 
16
<employees>
 
17
    <employee id="0"><name>Jim</name><age>25</age></employee>
 
18
    <employee id="1"><name>Joe</name><age>20</age></employee>
 
19
</employees>;
 
20
 
 
21
TEST(++nTest, true, emps.contains(emps));
 
22
 
 
23
// Martin - bug 289706
 
24
 
 
25
expect = 'gods.contains(\'Kibo\')==false && (gods==\'Kibo\')==false';
 
26
 
 
27
var gods = <gods>
 
28
  <god>Kibo</god>
 
29
  <god>Xibo</god>
 
30
</gods>;
 
31
 
 
32
printStatus('XML markup is:\r\n' + gods.toXMLString());
 
33
 
 
34
var string = 'Kibo';
 
35
actual = 'gods.contains(\'' + string + '\')==' + gods.contains(string);
 
36
actual += ' && ';
 
37
actual += '(gods==\'' + string + '\')==' + (gods == string);
 
38
 
 
39
TEST(++nTest, expect, actual);
 
40
 
 
41
// Martin - bug 289790
 
42
 
 
43
function containsTest(xmlObject, value)
 
44
{
 
45
    var comparison    = (xmlObject == value);
 
46
    var containsCheck = xmlObject.contains(value);
 
47
    var result        = (comparison == containsCheck);
 
48
 
 
49
    printStatus('Comparing ' + xmlObject.nodeKind() +
 
50
                ' against ' + (typeof value) + ':');
 
51
 
 
52
    printStatus('==: ' + comparison + '; contains: ' + containsCheck +
 
53
                '; check ' + (result ? 'passed' : 'failed'));
 
54
    return result;
 
55
}
 
56
 
 
57
actual = containsTest(new XML('Kibo'), 'Kibo');
 
58
TEST(++nTest, true, actual);
 
59
 
 
60
actual = containsTest(<god>Kibo</god>, 'Kibo');
 
61
TEST(++nTest, true, actual);
 
62
 
 
63
END();