diff --git a/core/block_events.js b/core/block_events.js
index 4a3f82773..c016bca46 100644
--- a/core/block_events.js
+++ b/core/block_events.js
@@ -197,7 +197,7 @@ Blockly.Events.Change.prototype.run = function(forward) {
oldMutation = oldMutationDom && Blockly.Xml.domToText(oldMutationDom);
}
if (block.domToMutation) {
- var dom = Blockly.Xml.textToDom(value || '');
+ var dom = Blockly.Xml.textToDom(value || '');
block.domToMutation(dom);
}
Blockly.Events.fire(new Blockly.Events.Change(
diff --git a/tests/xml/README.txt b/tests/xml/README.txt
new file mode 100644
index 000000000..8fe34d8c1
--- /dev/null
+++ b/tests/xml/README.txt
@@ -0,0 +1,11 @@
+This directory contains the schema for validating Blockly XML files:
+* blockly.xsd
+
+Also included are three sample XML files:
+* workspace.xml - XML for a complicated workspace.
+* toolbox.xml - XML for a complicated toolbox with categories and separators.
+* invalid.xml - XML that violates the DTD.
+
+Testing can be performed using an online tool:
+https://www.corefiling.com/opensource/schemaValidate/
+http://www.utilities-online.info/xsdvalidation/
diff --git a/tests/xml/blockly.xsd b/tests/xml/blockly.xsd
new file mode 100644
index 000000000..4ab48e443
--- /dev/null
+++ b/tests/xml/blockly.xsd
@@ -0,0 +1,178 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/tests/xml/invalid.xml b/tests/xml/invalid.xml
new file mode 100644
index 000000000..5debaafd4
--- /dev/null
+++ b/tests/xml/invalid.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
diff --git a/tests/xml/toolbox.xml b/tests/xml/toolbox.xml
new file mode 100644
index 000000000..63474ece7
--- /dev/null
+++ b/tests/xml/toolbox.xml
@@ -0,0 +1,311 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 10
+
+
+
+
+
+ i
+
+
+ 1
+
+
+
+
+ 10
+
+
+
+
+ 1
+
+
+
+
+
+
+
+
+ 123
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+
+ 100
+
+
+
+
+
+
+ 1
+
+
+
+
+ 100
+
+
+
+
+
+
+
+
+
+
+
+
+ 5
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ randomize
+
+
+ x
+
+
+ 1
+
+
+
+
+
+
+ list
+
+
+
+
+
+
+ 1
+
+
+
+
+ y
+
+
+
+
+ 1
+
+
+
+
+
+
+ list
+
+
+
+
+
+
+
+
+ temp
+
+
+
+ GET
+ FROM_START
+
+
+ y
+
+
+
+
+ list
+
+
+
+
+
+
+
+
+ y
+
+
+
+
+ list
+
+
+
+
+
+ GET
+ FROM_START
+
+
+ x
+
+
+
+
+ list
+
+
+
+
+
+
+
+
+ x
+
+
+
+
+ list
+
+
+
+
+ temp
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 'Twas brillig, and the slithy toves
+
+
+
+
+
+
+ Did gyre and gimble in the wabe:
+
+
+
+
+
+
+ All mimsy were the borogroves,
+
+
+
+
+
+
+ And the mome raths outgrabe.
+
+
+
+
+
+
+
+
+
+
+
+
+ "Beware the Jabberwock, my son!
+
+
+
+
+
+
+ The jaws that bite, the claws that catch!
+
+
+
+
+
+
+ Beware the Jubjub bird, and shun
+
+
+
+
+
+
+ The frumious Bandersnatch!"
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/tests/xml/workspace.xml b/tests/xml/workspace.xml
new file mode 100644
index 000000000..708544b92
--- /dev/null
+++ b/tests/xml/workspace.xml
@@ -0,0 +1,114 @@
+
+
+ x
+ i
+ text
+
+ This is a workspace comment.
+ This is a new line on the workspace comment.
+
+
+
+
+
+
+ bar
+ Describe this function...
+
+
+
+
+
+ LT
+
+
+
+ FIRST
+ FROM_START
+
+
+ text
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <html>
+
+
+
+
+
+
+ i
+
+
+ 1
+
+
+
+
+
+
+
+
+
+ foo
+ This function does...
+
+...nothing!
+
+
+
+
+
+
+ TRUE
+
+
+
+
+
+
+ 100
+
+
+
+
+ 50
+
+
+
+
+ 0
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+