Update my invariants a bit
authorAryeh Gregor <AryehGregor+gitcommit@gmail.com>
Thu, 14 Jul 2011 13:18:24 -0600
changeset 426 66e76e5f2d15
parent 425 84bc0c9e5e69
child 427 0de6ed26529c
Update my invariants a bit
editcommands.html
source.html
tests.js
--- a/editcommands.html	Thu Jul 14 12:47:14 2011 -0600
+++ b/editcommands.html	Thu Jul 14 13:18:24 2011 -0600
@@ -706,26 +706,33 @@
 <p>All of these methods must treat their <var title="">command</var> argument <a class=external data-anolis-spec=domcore href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#ascii-case-insensitive title="ASCII case-insensitive">ASCII
 case-insensitively</a>.
 
-<p>The methods in this section have been designed so that the following
+<div class=note>
+<p>The methods in this section have mostly been designed so that the following
 invariants hold after <code><a href=#execcommand()>execCommand()</a></code> is called, assuming it didn't
 throw an exception:
 
 <ul>
-  <li><code><a href=#querycommandindeterm()>queryCommandIndeterm()</a></code> will return false (or throw an
+  <li><code title="">queryCommandIndeterm()</code> will return false (or throw an
   exception).
 
-  <li><code><a href=#querycommandstate()>queryCommandState()</a></code> will return the opposite of what it did
-  before <code><a href=#execcommand()>execCommand()</a></code> was called (or throw an exception).
-
-  <li><code><a href=#querycommandvalue()>queryCommandValue()</a></code> will return something equivalent to the
-  value passed to <code><a href=#execcommand()>execCommand()</a></code> (or throw an exception).
+  <li><code title="">queryCommandState()</code> will return the opposite of what it did
+  before <code title="">execCommand()</code> was called (or throw an exception).
+
+  <li><code title="">queryCommandValue()</code> will return something equivalent to the
+  value passed to <code title="">execCommand()</code> (or throw an exception).
   "Equivalent" here needs to be construed broadly in some cases, such as
-  <a href=#the-fontsize-command>the <code title="">fontSize</code> command</a>.
+  <code title="">fontSize</code>.
 </ul>
 
-<p>The first two points do not always hold for <a href=#the-strikethrough-command>the <code title="">strikethrough</code> command</a> or <a href=#the-underline-command>the <code title="">underline</code> command</a>, because it can be impossible to unset
-text-decoration in CSS, but all three points otherwise hold in all cases
-barring bugs.
+<p>The first two points do not always hold for <code title="">strikethrough</code>
+or <code title="">underline</code>, because it can be impossible to unset
+text-decoration in CSS.  Also, by design, the state of <code title="">insertOrderedList</code> and <code title="">insertOrderedList</code> might
+not be the opposite after calling as before calling.  Finally, the state of the
+various <code title="">justify</code> commands should always be true after
+calling, and the value should always be the appropriate string ("center",
+"justify", "left", or "right").  Any other deviations from these invariants are
+bugs in the specification.
+</div>
 
 
 <h2 id=common-definitions><span class=secno>5 </span>Common definitions</h2>
--- a/source.html	Thu Jul 14 12:47:14 2011 -0600
+++ b/source.html	Thu Jul 14 13:18:24 2011 -0600
@@ -655,28 +655,34 @@
 data-anolis-spec=domcore title="ASCII case-insensitive">ASCII
 case-insensitively</span>.
 
-<p>The methods in this section have been designed so that the following
+<div class=note>
+<p>The methods in this section have mostly been designed so that the following
 invariants hold after <code>execCommand()</code> is called, assuming it didn't
 throw an exception:
 
 <ul>
-  <li><code>queryCommandIndeterm()</code> will return false (or throw an
+  <li><code title>queryCommandIndeterm()</code> will return false (or throw an
   exception).
 
-  <li><code>queryCommandState()</code> will return the opposite of what it did
-  before <code>execCommand()</code> was called (or throw an exception).
-
-  <li><code>queryCommandValue()</code> will return something equivalent to the
-  value passed to <code>execCommand()</code> (or throw an exception).
+  <li><code title>queryCommandState()</code> will return the opposite of what it did
+  before <code title>execCommand()</code> was called (or throw an exception).
+
+  <li><code title>queryCommandValue()</code> will return something equivalent to the
+  value passed to <code title>execCommand()</code> (or throw an exception).
   "Equivalent" here needs to be construed broadly in some cases, such as
-  <span>the <code title>fontSize</code> command</span>.
+  <code title>fontSize</code>.
 </ul>
 
-<p>The first two points do not always hold for <span>the <code
-title>strikethrough</code> command</span> or <span>the <code
-title>underline</code> command</span>, because it can be impossible to unset
-text-decoration in CSS, but all three points otherwise hold in all cases
-barring bugs.
+<p>The first two points do not always hold for <code title>strikethrough</code>
+or <code title>underline</code>, because it can be impossible to unset
+text-decoration in CSS.  Also, by design, the state of <code
+title>insertOrderedList</code> and <code title>insertOrderedList</code> might
+not be the opposite after calling as before calling.  Finally, the state of the
+various <code title>justify</code> commands should always be true after
+calling, and the value should always be the appropriate string ("center",
+"justify", "left", or "right").  Any other deviations from these invariants are
+bugs in the specification.
+</div>
 <!-- @} -->
 
 <h2>Common definitions</h2>
--- a/tests.js	Thu Jul 14 12:47:14 2011 -0600
+++ b/tests.js	Thu Jul 14 13:18:24 2011 -0600
@@ -3420,13 +3420,20 @@
 
 	beforeDiv.appendChild(document.createElement("span"));
 	afterDiv.appendChild(document.createElement("span"));
-	if (beforeState !== "Exception" || afterState !== "Exception") {
+	if ((beforeState !== "Exception" || afterState !== "Exception")
+	&& !/insert(un)?orderedlist|justify(center|full|left|right)/.test(command)) {
 		beforeDiv.lastChild.className =
 		afterDiv.lastChild.className =
 			beforeState !== "Exception" && afterState !== "Exception" && beforeState === !afterState
 				? "good-result"
 				: "bad-result";
 	}
+	if (/^justify(center|full|left|right)$/.test(command)) {
+		afterDiv.lastChild.className =
+			beforeState !== "Exception" && afterState !== "Exception" && afterState
+				? "good-result"
+				: "bad-result";
+	}
 	beforeDiv.lastChild.textContent = "state " + beforeState;
 	afterDiv.lastChild.textContent = "state " + afterState;
 
@@ -3449,6 +3456,14 @@
 				? "good-result"
 				: "bad-result";
 	}
+	if (/^justify(center|full|left|right)$/.test(command)) {
+		var expectedValue = command == "justifyfull"
+			? "justify"
+			: command.replace("justify", "");
+		afterDiv.lastChild.className = afterValue == expectedValue
+			? "good-result"
+			: "bad-result";
+	}
 	beforeDiv.lastChild.textContent = "value " + beforeValue;
 	afterDiv.lastChild.textContent = "value " + afterValue;