Bug 1101364 - Part 2: Add Mochitest. r=mats
--- a/dom/base/test/mochitest.ini
+++ b/dom/base/test/mochitest.ini
@@ -650,16 +650,18 @@ skip-if = buildapp == 'mulet' || buildap
[test_bug922681.html]
[test_bug927196.html]
[test_bug945152.html]
run-if = os == 'linux'
[test_bug982153.html]
[test_bug1008126.html]
run-if = os == 'linux'
[test_bug1057176.html]
+[test_bug1101364.html]
+skip-if = buildapp == 'mulet' || buildapp == 'b2g' || toolkit == 'android'
[test_caretPositionFromPoint.html]
[test_classList.html]
# This test fails on the Mac for some reason
[test_copyimage.html]
skip-if = (buildapp == 'b2g' && toolkit != 'gonk') || toolkit != 'gtk2' && toolkit != 'gtk3' && toolkit != 'windows' || e10s #b2g-desktop(Bug 931116, b2g desktop specific, initial triage)
[test_copypaste.html]
skip-if = buildapp == 'b2g' || toolkit == 'android' || e10s #bug 904183 # b2g(clipboard undefined) b2g-debug(clipboard undefined) b2g-desktop(clipboard undefined)
[test_copypaste.xhtml]
new file mode 100644
--- /dev/null
+++ b/dom/base/test/test_bug1101364.html
@@ -0,0 +1,73 @@
+<!DOCTYPE>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=1101364
+-->
+<head>
+<title>Test for Bug 1101364</title>
+ <script src="/tests/SimpleTest/SimpleTest.js"></script>
+ <script src="/tests/SimpleTest/WindowSnapshot.js"></script>
+ <script src="/tests/SimpleTest/EventUtils.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+ <style>
+ #test1 {
+ -moz-user-select: none;
+ }
+
+ #testDiv, #test2 {
+ -moz-user-select: text;
+ }
+ </style>
+</head>
+<body id='body'>
+
+<iframe id="test1" src="data:text/html,<h1 id='test1' style='-moz-user-select:none'>Header</h1><div id='testDiv'>test1</div>"></iframe>
+<iframe id="test2" src="data:text/html,<div contenteditable id='test2'>AAA<span id='test2Inner'>BBB</span></div>"></iframe>
+<pre id="test">
+<script class="testbody" type="text/javascript">
+
+function test()
+{
+ var iframe1 = document.getElementById('test1');
+ iframe1.focus();
+ var Ci = SpecialPowers.Ci;
+ var webnav = SpecialPowers.wrap(iframe1.contentWindow).QueryInterface(Ci.nsIInterfaceRequestor)
+ .getInterface(Ci.nsIWebNavigation)
+ var docShell = webnav.QueryInterface(Ci.nsIDocShell);
+
+ // test1
+ docShell.doCommand("cmd_selectAll");
+ var withoutContenteditable = snapshotWindow(iframe1.contentWindow);
+
+ iframe1.contentDocument.getElementById('testDiv').setAttribute('contentEditable', true);
+ docShell.doCommand("cmd_selectAll");
+ var withContenteditable = snapshotWindow(iframe1.contentWindow);
+ dump(withoutContenteditable.toDataURL());
+ dump(withContenteditable.toDataURL());
+
+ ok(compareSnapshots(withoutContenteditable, withContenteditable, true)[0], 'Select all should look identical');
+
+ // test2
+ var iframe2 = document.getElementById('test2');
+ iframe2.focus();
+ var webnav = SpecialPowers.wrap(iframe2.contentWindow).QueryInterface(Ci.nsIInterfaceRequestor)
+ .getInterface(Ci.nsIWebNavigation)
+ var docShell = webnav.QueryInterface(Ci.nsIDocShell);
+ var test2Inner = iframe2.contentDocument.getElementById('test2Inner');
+ test2Inner.style.MozUserSelect = 'text';
+ docShell.doCommand("cmd_selectAll");
+ var withoutUserSelect = snapshotWindow(iframe2.contentWindow);
+
+ test2Inner.style.MozUserSelect = 'none';
+ docShell.doCommand("cmd_selectAll");
+ var withUserSelect = snapshotWindow(iframe2.contentWindow);
+ ok(compareSnapshots(withoutUserSelect, withUserSelect, true)[0], 'Editable fields should ignore user select style');
+
+ SimpleTest.finish();
+}
+window.onload = function() { setTimeout(test, 0); };
+SimpleTest.waitForExplicitFinish();
+</script>
+</pre>
+</body>
+</html>