Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(46)

Unified Diff: LayoutTests/fast/dom/Element/script-tests/setAttributeNS-namespace-err.js

Issue 740223003: Revive tests for Document.createAttributeNS() and Element.setAttributeNodeNS() (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: deprecation messages Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: LayoutTests/fast/dom/Element/script-tests/setAttributeNS-namespace-err.js
diff --git a/LayoutTests/fast/dom/DOMImplementation/script-tests/createDocument-namespace-err.js b/LayoutTests/fast/dom/Element/script-tests/setAttributeNS-namespace-err.js
similarity index 67%
copy from LayoutTests/fast/dom/DOMImplementation/script-tests/createDocument-namespace-err.js
copy to LayoutTests/fast/dom/Element/script-tests/setAttributeNS-namespace-err.js
index b0291b2cce22c69f192fd1d788ae906db0b1b435..dbe8f561ddafb30158892e61a74a1658f4ffec21 100644
--- a/LayoutTests/fast/dom/DOMImplementation/script-tests/createDocument-namespace-err.js
+++ b/LayoutTests/fast/dom/Element/script-tests/setAttributeNS-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("setAttributeNS tests adapted from createAttributeNS which in turn were adapted from createElementNS tests attached to webkit bug 16833");
function assert(c, m)
{
@@ -88,48 +82,41 @@ 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 element = document.createElement("div");
+ var setFunction = element.setAttributeNS;
+ var setFunctionName = "element.setAttributeNS";
+ var value = "'value'";
- // 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 msg = createFunctionName + "(" + argStr + ")";
+ var argStr = sourceify(test.args[0]) + ", " + sourceify(test.args[1]) + ", " + value;
+ var msg = setFunctionName + "(" + argStr + ")";
if ("message" in test)
msg += "; " + test.message;
try {
- doc[createFunctionName].apply(doc, argsWithExtraLastNull);
+ setFunction.apply(element, test.args.concat([value]));
assert(!("code" in test), msg);
} catch (e) {
assertEquals(e.code, test.code || "expected no exception", msg);
@@ -137,7 +124,4 @@ function runNSTests(tests, doc, createFunctionName)
}
}
-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."');
-
-runNSTests(allNSTests, document.implementation, "createDocument");
+runNSTests();

Powered by Google App Engine
This is Rietveld 408576698