ms2ger avatar ms2ger committed 2e3beb9

Initial commit.

Comments (0)

Files changed (5)

+^\.hg
+^\.mq
+syntax: glob
+status
+guards
+From: Ms2ger <ms2ger@gmail.com>
+Add some tests for the named property getter on the document object.
+
+diff --git a/html/dom/documents/dom-tree-accessors/nameditem-01.html b/html/dom/documents/dom-tree-accessors/nameditem-01.html
+--- a/html/dom/documents/dom-tree-accessors/nameditem-01.html
++++ b/html/dom/documents/dom-tree-accessors/nameditem-01.html
+@@ -1,19 +1,18 @@
+ <!DOCTYPE html>
+ <title>Named items: img id &amp; name</title>
+ <link rel="author" title="Ms2ger" href="mailto:ms2ger@gmail.com">
+-<link rel="help" href="http://www.whatwg.org/html5/#dom-document-nameditem">
+-<link rel="stylesheet" href="/resources/testharness.css">
++<link rel="help" href="http://www.whatwg.org/html/#dom-document-nameditem">
+ <script src="/resources/testharness.js"></script>
+ <script src="/resources/testharnessreport.js"></script>
+ <div id="log"></div>
+ <div id="test">
+ <img id="a" name="b">
+ </div>
+ <script>
+ test(function() {
+   assert_equals(document.a, document.getElementsByTagName("img")[0]);
+   assert_equals(document['a'], document.getElementsByTagName("img")[0]);
+   assert_equals(document.b, document.getElementsByTagName("img")[0]);
+   assert_equals(document['b'], document.getElementsByTagName("img")[0]);
+-});
++}, "img elements that have a name and id attribute, should be accessible by both values.");
+ </script>
+diff --git a/html/dom/documents/dom-tree-accessors/nameditem-02.html b/html/dom/documents/dom-tree-accessors/nameditem-02.html
+new file mode 100644
+--- /dev/null
++++ b/html/dom/documents/dom-tree-accessors/nameditem-02.html
+@@ -0,0 +1,91 @@
++<!DOCTYPE html>
++<title>Named items: iframes</title>
++<link rel="author" title="Ms2ger" href="mailto:ms2ger@gmail.com">
++<link rel="help" href="http://www.whatwg.org/html/#dom-document-nameditem">
++<script src="/resources/testharness.js"></script>
++<script src="/resources/testharnessreport.js"></script>
++<div id="log"></div>
++<div id="test">
++<iframe name="test1"></iframe>
++
++<iframe name="test2"></iframe>
++<iframe name="test2"></iframe>
++
++<iframe name="test3"></iframe>
++<img name="test3">
++
++<img name="test4">
++<iframe name="test4"></iframe>
++
++<iframe id="test5"></iframe>
++
++<iframe name="test6" id="fail"></iframe>
++
++<iframe name="fail" id="test7"></iframe>
++
++<iframe name="42"></iframe>
++</div>
++<script>
++test(function() {
++  var iframe = document.getElementsByTagName("iframe")[0];
++  assert_equals(iframe.name, "test1");
++
++  assert_true("test1" in document, '"test1" in document should be true');
++  assert_equals(document.test1, iframe.contentWindow);
++}, "If the only named item is an iframe, the contentWindow should be returned.");
++test(function() {
++  var iframe1 = document.getElementsByTagName("iframe")[1];
++  assert_equals(iframe1.name, "test2");
++  var iframe2 = document.getElementsByTagName("iframe")[2];
++  assert_equals(iframe2.name, "test2");
++
++  assert_true("test2" in document, '"test2" in document should be true');
++  var collection = document.test2;
++  assert_true(collection instanceof HTMLCollection, "collection should be an HTMLCollection");
++  assert_array_equals(collection, [iframe1, iframe2]);
++}, "If the there are two iframes, a collection should be returned.");
++test(function() {
++  var iframe = document.getElementsByTagName("iframe")[3];
++  assert_equals(iframe.name, "test3");
++  var img = document.getElementsByTagName("img")[0];
++  assert_equals(img.name, "test3");
++
++  assert_true("test3" in document, '"test3" in document should be true');
++  var collection = document.test3;
++  assert_true(collection instanceof HTMLCollection, "collection should be an HTMLCollection");
++  assert_array_equals(collection, [iframe, img]);
++}, "If the there are an iframe and another element (iframe first), a collection should be returned.");
++test(function() {
++  var iframe = document.getElementsByTagName("iframe")[4];
++  assert_equals(iframe.name, "test4");
++  var img = document.getElementsByTagName("img")[1];
++  assert_equals(img.name, "test4");
++
++  assert_true("test4" in document, '"test4" in document should be true');
++  var collection = document.test4;
++  assert_true(collection instanceof HTMLCollection, "collection should be an HTMLCollection");
++  assert_array_equals(collection, [img, iframe]);
++}, "If the there are an iframe and another element (iframe last), a collection should be returned.");
++test(function() {
++  assert_false("test5" in document, '"test5" in document should be false');
++  assert_equals(document.test5, undefined);
++}, "If an iframe has an id and no name, it should not be returned.");
++test(function() {
++  var iframe = document.getElementsByTagName("iframe")[6];
++  assert_equals(iframe.name, "test6");
++
++  assert_true("test6" in document, '"test6" in document should be true');
++  assert_equals(document.test6, iframe.contentWindow);
++}, "If an iframe has a name and a different id, it should be returned by its name.");
++test(function() {
++  assert_false("test7" in document, '"test7" in document should be false');
++  assert_equals(document.test7, undefined);
++}, "If an iframe has an id and a different name, it should not be returned by its id.");
++test(function() {
++  var iframe = document.getElementsByTagName("iframe")[8];
++  assert_equals(iframe.name, "42");
++
++  assert_true(42 in document, '42 in document should be true');
++  assert_equals(document[42], iframe.contentWindow);
++}, "An iframe whose name looks like an array index should work.");
++</script>
+table-border
+window-props
+namedItem
+Add some reftests for table[border].
+
+diff --git a/html/rendering/non-replaced-elements/tables/MANIFEST b/html/rendering/non-replaced-elements/tables/MANIFEST
+--- a/html/rendering/non-replaced-elements/tables/MANIFEST
++++ b/html/rendering/non-replaced-elements/tables/MANIFEST
+@@ -1,1 +1,3 @@
+ ref table-width-150percent.html == table-width-150percent-ref.html
++ref table-border-1.html == table-border-1-ref.html
++ref table-border-2.html != table-border-2-notref.html == table-border-2-ref.html
+diff --git a/html/rendering/non-replaced-elements/tables/table-border-1-ref.html b/html/rendering/non-replaced-elements/tables/table-border-1-ref.html
+new file mode 100644
+--- /dev/null
++++ b/html/rendering/non-replaced-elements/tables/table-border-1-ref.html
+@@ -0,0 +1,46 @@
++<!DOCTYPE html>
++<meta charset=utf-8>
++<title>Table borders</title>
++<style>
++table {
++  border-width: 1px;
++  border-style: outset;
++}
++td {
++  border-width: 1px;
++  border-style: inset;
++}
++</style>
++<table>
++<tr><td>Test
++</table>
++<table>
++<tr><td>Test
++</table>
++<table>
++<tr><td>Test
++</table>
++<table>
++<tr><td>Test
++</table>
++<table>
++<tr><td>Test
++</table>
++<table>
++<tr><td>Test
++</table>
++<table>
++<tr><td>Test
++</table>
++<table>
++<tr><td>Test
++</table>
++<table>
++<tr><td>Test
++</table>
++<table>
++<tr><td>Test
++</table>
++<table>
++<tr><td>Test
++</table>
+diff --git a/html/rendering/non-replaced-elements/tables/table-border-1.html b/html/rendering/non-replaced-elements/tables/table-border-1.html
+new file mode 100644
+--- /dev/null
++++ b/html/rendering/non-replaced-elements/tables/table-border-1.html
+@@ -0,0 +1,36 @@
++<!DOCTYPE html>
++<meta charset=utf-8>
++<title>Table borders</title>
++<table border>
++<tr><td>Test
++</table>
++<table border="">
++<tr><td>Test
++</table>
++<table border=null>
++<tr><td>Test
++</table>
++<table border=undefined>
++<tr><td>Test
++</table>
++<table border=foo>
++<tr><td>Test
++</table>
++<table border=1>
++<tr><td>Test
++</table>
++<table border=1foo>
++<tr><td>Test
++</table>
++<table border=1%>
++<tr><td>Test
++</table>
++<table border=-1>
++<tr><td>Test
++</table>
++<table border=-1foo>
++<tr><td>Test
++</table>
++<table border=-1%>
++<tr><td>Test
++</table>
+diff --git a/html/rendering/non-replaced-elements/tables/table-border-2-notref.html b/html/rendering/non-replaced-elements/tables/table-border-2-notref.html
+new file mode 100644
+--- /dev/null
++++ b/html/rendering/non-replaced-elements/tables/table-border-2-notref.html
+@@ -0,0 +1,40 @@
++<!DOCTYPE html>
++<meta charset=utf-8>
++<title>Table borders</title>
++<style>
++table {
++  border-width: 1px;
++  border-style: outset;
++}
++td {
++  border-width: 1px;
++  border-style: inset;
++}
++</style>
++<table>
++<tr><td>Test
++</table>
++<table>
++<tr><td>Test
++</table>
++<table>
++<tr><td>Test
++</table>
++<table>
++<tr><td>Test
++</table>
++<table>
++<tr><td>Test
++</table>
++<table>
++<tr><td>Test
++</table>
++<table>
++<tr><td>Test
++</table>
++<table>
++<tr><td>Test
++</table>
++<table>
++<tr><td>Test
++</table>
+diff --git a/html/rendering/non-replaced-elements/tables/table-border-2-ref.html b/html/rendering/non-replaced-elements/tables/table-border-2-ref.html
+new file mode 100644
+--- /dev/null
++++ b/html/rendering/non-replaced-elements/tables/table-border-2-ref.html
+@@ -0,0 +1,30 @@
++<!DOCTYPE html>
++<meta charset=utf-8>
++<title>Table borders</title>
++<table>
++<tr><td>Test
++</table>
++<table>
++<tr><td>Test
++</table>
++<table>
++<tr><td>Test
++</table>
++<table>
++<tr><td>Test
++</table>
++<table>
++<tr><td>Test
++</table>
++<table>
++<tr><td>Test
++</table>
++<table>
++<tr><td>Test
++</table>
++<table>
++<tr><td>Test
++</table>
++<table>
++<tr><td>Test
++</table>
+diff --git a/html/rendering/non-replaced-elements/tables/table-border-2.html b/html/rendering/non-replaced-elements/tables/table-border-2.html
+new file mode 100644
+--- /dev/null
++++ b/html/rendering/non-replaced-elements/tables/table-border-2.html
+@@ -0,0 +1,30 @@
++<!DOCTYPE html>
++<meta charset=utf-8>
++<title>Table borders</title>
++<table border=0>
++<tr><td>Test
++</table>
++<table border=0foo>
++<tr><td>Test
++</table>
++<table border=0%>
++<tr><td>Test
++</table>
++<table border=+0>
++<tr><td>Test
++</table>
++<table border=+0foo>
++<tr><td>Test
++</table>
++<table border=+0%>
++<tr><td>Test
++</table>
++<table border=-0>
++<tr><td>Test
++</table>
++<table border=-0foo>
++<tr><td>Test
++</table>
++<table border=-0%>
++<tr><td>Test
++</table>
+Add some tests for properties of window and the named properties object.
+
+diff --git a/common/propdesc.js b/common/propdesc.js
+new file mode 100644
+--- /dev/null
++++ b/common/propdesc.js
+@@ -0,0 +1,16 @@
++function assert_data_propdesc(pd, Writable, Enumerable, Configurable) {
++  assert_equals(typeof pd, "object");
++  assert_equals(pd.writable, Writable);
++  assert_equals(pd.enumerable, Enumerable);
++  assert_equals(pd.configurable, Configurable);
++}
++
++function assert_accessor_propdesc(pd, hasSetter, Enumerable, Configurable) {
++  assert_equals(typeof pd, "object");
++  assert_equals(typeof pd.get, "function");
++  assert_equals("set" in pd, hasSetter,
++                "Should have a setter for writable and replaceable attributes");
++  assert_equals(typeof pd.set, hasSetter ? "function" : "undefined");
++  assert_equals(pd.enumerable, Enumerable);
++  assert_equals(pd.configurable, Configurable);
++}
+diff --git a/html/browsers/the-window-object/window-named-properties.html b/html/browsers/the-window-object/named-access-on-the-window-object/window-constructor.html
+rename from html/browsers/the-window-object/window-named-properties.html
+rename to html/browsers/the-window-object/named-access-on-the-window-object/window-constructor.html
+--- a/html/browsers/the-window-object/window-named-properties.html
++++ b/html/browsers/the-window-object/named-access-on-the-window-object/window-constructor.html
+@@ -1,70 +1,31 @@
+ <!doctype html>
+ <meta charset=utf-8>
+-<title>Changes to named properties of the window object</title>
++<title>window.constructor</title>
+ <link rel="author" title="Ms2ger" href="ms2ger@gmail.com">
+-<link rel="author" title="Boris Zbarsky" href="bzbarsky@mit.edu">
+ <link rel="help" href="http://www.whatwg.org/html/#window">
+ <link rel="help" href="http://www.whatwg.org/html/#dom-window-nameditem">
+ <link rel="help" href="http://dev.w3.org/2006/webapi/WebIDL/#named-properties-object">
++<link rel="help" href="http://dev.w3.org/2006/webapi/WebIDL/#interface-prototype-object">
+ <script src="/resources/testharness.js"></script>
+ <script src="/resources/testharnessreport.js"></script>
++<script src="../../../../common/propdesc.js"></script>
+ <div id=log></div>
+-<iframe name="bar"></iframe>
+ <iframe name="constructor"></iframe>
+ <script>
+-function assert_data_propdesc(pd, Writable, Enumerable, Configurable) {
+-  assert_equals(typeof pd, "object");
+-  assert_equals(pd.writable, Writable);
+-  assert_equals(pd.enumerable, Enumerable);
+-  assert_equals(pd.configurable, Configurable);
+-}
+-test(function() {
+-  assert_true("bar" in window, "bar not in window");
+-  assert_equals(window["bar"],
+-                document.getElementsByTagName("iframe")[0].contentWindow);
+-}, "Static name");
+-test(function() {
+-  assert_true("bar" in Window.prototype, "bar in Window.prototype");
+-  assert_false(Window.prototype.hasOwnProperty("bar"), "Window.prototype.hasOwnProperty(\"bar\")");
+-
+-  var gsp = Object.getPrototypeOf(Object.getPrototypeOf(window));
+-  assert_true("bar" in gsp, "bar in gsp");
+-  assert_true(gsp.hasOwnProperty("bar"), "gsp.hasOwnProperty(\"bar\")");
+-  assert_data_propdesc(Object.getOwnPropertyDescriptor(gsp, "bar"),
+-                       false, true, true);
+-}, "Static name on the prototype");
+ test(function() {
+   assert_equals(window.constructor, Window);
+   assert_false(window.hasOwnProperty("constructor"), "window.constructor should not be an own property.");
+ 
+   var proto = Object.getPrototypeOf(window);
+   assert_equals(proto.constructor, Window);
+   assert_true("constructor" in proto, "constructor in proto");
+   assert_data_propdesc(Object.getOwnPropertyDescriptor(proto, "constructor"),
+                        true, false, true);
+ 
+   var gsp = Object.getPrototypeOf(proto);
+   assert_true("constructor" in gsp, "constructor in gsp");
+   assert_true(gsp.hasOwnProperty("constructor"), "gsp.hasOwnProperty(\"constructor\")");
+   assert_data_propdesc(Object.getOwnPropertyDescriptor(gsp, "constructor"),
+                        false, true, true);
+-}, "constructor");
+-var t = async_test("Dynamic name")
+-var t2 = async_test("Ghost name")
+-t.step(function() {
+-  var iframe = document.getElementsByTagName("iframe")[0];
+-  iframe.setAttribute("src", "data:text/html,<script>window.name='foo'<\/script>");
+-  iframe.onload = function() {
+-    t.step(function() {
+-      assert_true("foo" in window, "foo not in window");
+-      assert_equals(window["foo"], iframe.contentWindow);
+-    });
+-    t.done();
+-    t2.step(function() {
+-      assert_false("bar" in window, "bar still in window");
+-      assert_equals(window["bar"], undefined);
+-    });
+-    t2.done();
+-  };
+-});
++}, "constructor should be an own property of the interface prototype object");
+ </script>
+diff --git a/html/browsers/the-window-object/window-named-properties.html b/html/browsers/the-window-object/named-access-on-the-window-object/window-named-properties.html
+copy from html/browsers/the-window-object/window-named-properties.html
+copy to html/browsers/the-window-object/named-access-on-the-window-object/window-named-properties.html
+--- a/html/browsers/the-window-object/window-named-properties.html
++++ b/html/browsers/the-window-object/named-access-on-the-window-object/window-named-properties.html
+@@ -3,57 +3,36 @@
+ <title>Changes to named properties of the window object</title>
+ <link rel="author" title="Ms2ger" href="ms2ger@gmail.com">
+ <link rel="author" title="Boris Zbarsky" href="bzbarsky@mit.edu">
+ <link rel="help" href="http://www.whatwg.org/html/#window">
+ <link rel="help" href="http://www.whatwg.org/html/#dom-window-nameditem">
+ <link rel="help" href="http://dev.w3.org/2006/webapi/WebIDL/#named-properties-object">
+ <script src="/resources/testharness.js"></script>
+ <script src="/resources/testharnessreport.js"></script>
++<script src="../../../../common/propdesc.js"></script>
+ <div id=log></div>
+ <iframe name="bar"></iframe>
+ <iframe name="constructor"></iframe>
+ <script>
+-function assert_data_propdesc(pd, Writable, Enumerable, Configurable) {
+-  assert_equals(typeof pd, "object");
+-  assert_equals(pd.writable, Writable);
+-  assert_equals(pd.enumerable, Enumerable);
+-  assert_equals(pd.configurable, Configurable);
+-}
+ test(function() {
+   assert_true("bar" in window, "bar not in window");
+   assert_equals(window["bar"],
+                 document.getElementsByTagName("iframe")[0].contentWindow);
+ }, "Static name");
+ test(function() {
+   assert_true("bar" in Window.prototype, "bar in Window.prototype");
+   assert_false(Window.prototype.hasOwnProperty("bar"), "Window.prototype.hasOwnProperty(\"bar\")");
+ 
+   var gsp = Object.getPrototypeOf(Object.getPrototypeOf(window));
+   assert_true("bar" in gsp, "bar in gsp");
+   assert_true(gsp.hasOwnProperty("bar"), "gsp.hasOwnProperty(\"bar\")");
+   assert_data_propdesc(Object.getOwnPropertyDescriptor(gsp, "bar"),
+                        false, true, true);
+ }, "Static name on the prototype");
+-test(function() {
+-  assert_equals(window.constructor, Window);
+-  assert_false(window.hasOwnProperty("constructor"), "window.constructor should not be an own property.");
+-
+-  var proto = Object.getPrototypeOf(window);
+-  assert_equals(proto.constructor, Window);
+-  assert_true("constructor" in proto, "constructor in proto");
+-  assert_data_propdesc(Object.getOwnPropertyDescriptor(proto, "constructor"),
+-                       true, false, true);
+-
+-  var gsp = Object.getPrototypeOf(proto);
+-  assert_true("constructor" in gsp, "constructor in gsp");
+-  assert_true(gsp.hasOwnProperty("constructor"), "gsp.hasOwnProperty(\"constructor\")");
+-  assert_data_propdesc(Object.getOwnPropertyDescriptor(gsp, "constructor"),
+-                       false, true, true);
+-}, "constructor");
+ var t = async_test("Dynamic name")
+ var t2 = async_test("Ghost name")
+ t.step(function() {
+   var iframe = document.getElementsByTagName("iframe")[0];
+   iframe.setAttribute("src", "data:text/html,<script>window.name='foo'<\/script>");
+   iframe.onload = function() {
+     t.step(function() {
+       assert_true("foo" in window, "foo not in window");
+diff --git a/html/browsers/the-window-object/named-access-on-the-window-object/window-npo-setter.html b/html/browsers/the-window-object/named-access-on-the-window-object/window-npo-setter.html
+new file mode 100644
+--- /dev/null
++++ b/html/browsers/the-window-object/named-access-on-the-window-object/window-npo-setter.html
+@@ -0,0 +1,22 @@
++<!doctype html>
++<meta charset=utf-8>
++<title>Setting properties of the named properties object</title>
++<link rel="author" title="Ms2ger" href="ms2ger@gmail.com">
++<link rel="help" href="http://www.whatwg.org/html/#window">
++<link rel="help" href="http://www.whatwg.org/html/#dom-window-nameditem">
++<link rel="help" href="http://dev.w3.org/2006/webapi/WebIDL/#named-properties-object">
++<script src="/resources/testharness.js"></script>
++<script src="/resources/testharnessreport.js"></script>
++<script src="../../../../common/propdesc.js"></script>
++<div id=log></div>
++<script>
++test(function() {
++  var proto = Object.getPrototypeOf(window);
++  var gsp = Object.getPrototypeOf(proto);
++  gsp.foo = "bar";
++
++  assert_equals(window.foo, "bar", "Property should be visible on the window.");
++  assert_equals(proto.foo, "bar", "Property should be visible on the interface prototype object.");
++  assert_equals(gsp.foo, "bar", "Property should be visible on the named properties object.");
++}, "constructor should be an own property of the interface prototype object");
++</script>
+diff --git a/html/browsers/the-window-object/window-properties.html b/html/browsers/the-window-object/window-properties.html
+--- a/html/browsers/the-window-object/window-properties.html
++++ b/html/browsers/the-window-object/window-properties.html
+@@ -12,34 +12,19 @@
+ <link rel="help" href="http://www.whatwg.org/html/#windowbase64">
+ <link rel="help" href="http://www.whatwg.org/html/#windowsessionstorage">
+ <link rel="help" href="http://www.whatwg.org/html/#windowlocalstorage">
+ <link rel="help" href="https://dvcs.w3.org/hg/editing/raw-file/tip/editing.html#dom-window-getselection">
+ <link rel="help" href="http://dev.w3.org/csswg/cssom/#widl-def-Window">
+ <link rel="help" href="http://dev.w3.org/csswg/cssom-view/#widl-def-Window">
+ <script src="/resources/testharness.js"></script>
+ <script src="/resources/testharnessreport.js"></script>
++<script src="../../../common/propdesc.js"></script>
+ <div id=log></div>
+ <script>
+-function assert_data_propdesc(pd, Writable, Enumerable, Configurable) {
+-  assert_equals(typeof pd, "object");
+-  assert_equals(pd.writable, Writable);
+-  assert_equals(pd.enumerable, Enumerable);
+-  assert_equals(pd.configurable, Configurable);
+-}
+-function assert_accessor_propdesc(pd, hasSetter, Enumerable, Configurable) {
+-  assert_equals(typeof pd, "object");
+-  assert_equals(typeof pd.get, "function");
+-  assert_equals("set" in pd, hasSetter,
+-                "Should have a setter for writable and replaceable attributes");
+-  assert_equals(typeof pd.set, hasSetter ? "function" : "undefined");
+-  assert_equals(pd.enumerable, Enumerable);
+-  assert_equals(pd.configurable, Configurable);
+-}
+-
+ var unforgeableAttributes = [
+   "window",
+   "document",
+   "location",
+   "top"
+ ];
+ 
+ var replacableAttributes = [
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.