| Index: LayoutTests/fast/dom/Document/script-tests/createAttributeNS-namespace-err.js
|
| diff --git a/LayoutTests/fast/dom/DOMImplementation/script-tests/createDocument-namespace-err.js b/LayoutTests/fast/dom/Document/script-tests/createAttributeNS-namespace-err.js
|
| similarity index 65%
|
| copy from LayoutTests/fast/dom/DOMImplementation/script-tests/createDocument-namespace-err.js
|
| copy to LayoutTests/fast/dom/Document/script-tests/createAttributeNS-namespace-err.js
|
| index b0291b2cce22c69f192fd1d788ae906db0b1b435..18d2332cea1647134920af60b74d2199e35c93ee 100644
|
| --- a/LayoutTests/fast/dom/DOMImplementation/script-tests/createDocument-namespace-err.js
|
| +++ b/LayoutTests/fast/dom/Document/script-tests/createAttributeNS-namespace-err.js
|
| @@ -1,10 +1,4 @@
|
| -description("createDocument tests modeled after createElementNS tests from mozilla which were attached to webkit bug 16833");
|
| -
|
| -// document.implementation.createDocument() should throw the same set of errors
|
| -// as document.createElementNS()
|
| -// http://www.w3.org/TR/DOM-Level-3-Core/core.html#Level-2-Core-DOM-createDocument
|
| -// Thus we copied these test cases from:
|
| -// LayoutTests/fast/dom/Document/resources/createDocument-namespace-err.js
|
| +description("createAttirbuteNS tests adapted from createElementNS tests attached to webkit bug 16833");
|
|
|
| function assert(c, m)
|
| {
|
| @@ -29,13 +23,14 @@ function stringForExceptionCode(c)
|
| return c;
|
| }
|
|
|
| -function assertEquals(actual, expect, m)
|
| +function assertExceptionCode(exception, expect, m)
|
| {
|
| + var actual = exception.code;
|
| if (actual !== expect) {
|
| m += "; expected " + stringForExceptionCode(expect) + ", threw " + stringForExceptionCode(actual);
|
| testFailed(m);
|
| } else {
|
| - m += "; threw " + stringForExceptionCode(actual);;
|
| + m += "; threw " + exception.toString();
|
| testPassed(m);
|
| }
|
| }
|
| @@ -88,56 +83,49 @@ var allNSTests = [
|
| { args: ["http://www.w3.org/2000/xmlns/", "xmlns:test"] },
|
| { args: ["http://www.w3.org/XML/1998/namespace", "xml:test"] },
|
| { args: ["http://www.w3.org/XML/1998/namespace", "x:test"] },
|
| + { args: ["http://www.w3.org/2000/xmlns/", "xmlns"] }, // See http://www.w3.org/2000/xmlns/
|
| + { args: ["http://example.com/", "xmlns"], code: 14 }, // from the createAttributeNS section
|
| ];
|
|
|
| function sourceify(v)
|
| {
|
| switch (typeof v) {
|
| - case "undefined":
|
| - return v;
|
| - case "string":
|
| - return '"' + v.replace('"', '\\"') + '"';
|
| - default:
|
| - return String(v);
|
| - }
|
| -}
|
| + case "undefined":
|
| + return v;
|
|
|
| -function sourceifyArgs(args)
|
| -{
|
| - var copy = new Array(args.length);
|
| - for (var i = 0, sz = args.length; i < sz; i++)
|
| - copy[i] = sourceify(args[i]);
|
| + case "string":
|
| + return '"' + v.replace('"', '\\"') + '"';
|
|
|
| - return copy.join(", ");
|
| + default:
|
| + return String(v);
|
| + }
|
| }
|
|
|
| -function runNSTests(tests, doc, createFunctionName)
|
| +function runNSTests()
|
| {
|
| - for (var i = 0, sz = tests.length; i < sz; i++) {
|
| - var test = tests[i];
|
| + var createFunction = document.createAttributeNS;
|
| + var createFunctionName = "createAttributeNS";
|
| + var doc = document;
|
|
|
| - // Gecko throws "undefined" if createDocument isn't
|
| - // called with 3 arguments. Instead of modifying all
|
| - // of the values in the arrays above (which were taken from createElementNS tests)
|
| - // we will instead just hack the args list here.
|
| - var argsWithExtraLastNull = test.args.slice(); // copy the args arary
|
| - argsWithExtraLastNull.push(null);
|
| + for (var i = 0, sz = allNSTests.length; i < sz; i++) {
|
| + var test = allNSTests[i];
|
|
|
| var code = -1;
|
| - var argStr = sourceifyArgs(argsWithExtraLastNull);
|
| + var argStr = sourceify(test.args[0]) + ", " + sourceify(test.args[1]);
|
| var msg = createFunctionName + "(" + argStr + ")";
|
| if ("message" in test)
|
| msg += "; " + test.message;
|
| try {
|
| - doc[createFunctionName].apply(doc, argsWithExtraLastNull);
|
| + createFunction.apply(doc, test.args);
|
| assert(!("code" in test), msg);
|
| } catch (e) {
|
| - assertEquals(e.code, test.code || "expected no exception", msg);
|
| + assertExceptionCode(e, test.code || "expected no exception", msg);
|
| }
|
| }
|
| }
|
|
|
| -shouldThrow("document.implementation.createDocument()", '"TypeError: Failed to execute \'createDocument\' on \'DOMImplementation\': 2 arguments required, but only 0 present."');
|
| -shouldThrow("document.implementation.createDocument(\"http://www.example.com\")", '"TypeError: Failed to execute \'createDocument\' on \'DOMImplementation\': 2 arguments required, but only 1 present."');
|
| +// Moz throws a "Not enough arguments" exception in these, we don't:
|
| +shouldBeEqualToString("document.createAttributeNS().toString()", "[object Attr]");
|
| +shouldBeEqualToString("document.createAttributeNS(\"http://www.example.com\").toString()", "[object Attr]");
|
|
|
| -runNSTests(allNSTests, document.implementation, "createDocument");
|
| +runNSTests();
|
|
|