aboutsummaryrefslogtreecommitdiff
path: root/contexts/data/lib/closure-library/closure/goog/testing/editor/testhelper_test.html
diff options
context:
space:
mode:
Diffstat (limited to 'contexts/data/lib/closure-library/closure/goog/testing/editor/testhelper_test.html')
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/editor/testhelper_test.html177
1 files changed, 0 insertions, 177 deletions
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/editor/testhelper_test.html b/contexts/data/lib/closure-library/closure/goog/testing/editor/testhelper_test.html
deleted file mode 100644
index 56ad06e..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/editor/testhelper_test.html
+++ /dev/null
@@ -1,177 +0,0 @@
-<!DOCTYPE html>
-<html lang="en" dir="ltr">
-<head>
-<!--
-Copyright 2008 The Closure Library Authors. All Rights Reserved.
-
-Use of this source code is governed by the Apache License, Version 2.0.
-See the COPYING file for details.
--->
-<meta http-equiv="X-UA-Compatible" content="IE=edge">
- <title>Closure Unit Tests - goog.testing.editor.TestHelper</title>
- <script src="../../base.js"></script>
- <script>
- goog.require('goog.dom');
- goog.require('goog.dom.TagName');
- goog.require('goog.editor.node');
- goog.require('goog.testing.editor.TestHelper');
- goog.require('goog.testing.jsunit');
- </script>
-</head>
-<body>
-<div id="root"></div>
-<div id="root2">Root 2</div>
-<script type="text/javascript">
- var root = goog.dom.getElement('root');
- var helper;
-
- function setUp() {
- goog.dom.removeChildren(root);
- helper = new goog.testing.editor.TestHelper(root);
- }
-
- function tearDown() {
- helper.dispose();
- }
-
- function testSetRoot() {
- helper.setRoot(goog.dom.getElement('root2'));
- helper.assertHtmlMatches('Root 2');
- }
-
- function testSetupEditableElement() {
- helper.setUpEditableElement();
- assertTrue(goog.editor.node.isEditableContainer(root));
- }
-
- function testTearDownEditableElement() {
- helper.setUpEditableElement();
- assertTrue(goog.editor.node.isEditableContainer(root));
-
- helper.tearDownEditableElement();
- assertFalse(goog.editor.node.isEditableContainer(root));
- }
-
- function testFindNode() {
- // Test the easiest case.
- root.innerHTML = 'a<br>b';
- assertEquals(helper.findTextNode('a'), root.firstChild);
- assertEquals(helper.findTextNode('b'), root.lastChild);
- assertNull(helper.findTextNode('c'));
- }
-
- function testFindNodeDuplicate() {
- // Test duplicate.
- root.innerHTML = 'c<br>c';
- assertEquals('Should return first duplicate', helper.findTextNode('c'),
- root.firstChild);
- }
-
- function findNodeWithHierarchy() {
- // Test a more complicated hierarchy.
- root.innerHTML = '<div>a<p>b<span>c</span>d</p>e</div>';
- assertEquals(goog.dom.TagName.DIV,
- helper.findTextNode('a').parentNode.tagName);
- assertEquals(goog.dom.TagName.P,
- helper.findTextNode('b').parentNode.tagName);
- assertEquals(goog.dom.TagName.SPAN,
- helper.findTextNode('c').parentNode.tagName);
- assertEquals(goog.dom.TagName.P,
- helper.findTextNode('d').parentNode.tagName);
- assertEquals(goog.dom.TagName.DIV,
- helper.findTextNode('e').parentNode.tagName);
- }
-
- function setUpAssertHtmlMatches() {
- var tag1, tag2;
- if (goog.userAgent.IE) {
- tag1 = goog.dom.TagName.DIV;
- } else if (goog.userAgent.WEBKIT) {
- tag1 = goog.dom.TagName.P;
- tag2 = goog.dom.TagName.BR;
- } else if (goog.userAgent.GECKO) {
- tag1 = goog.dom.TagName.SPAN;
- tag2 = goog.dom.TagName.BR;
- }
-
- var parent = goog.dom.createDom(goog.dom.TagName.DIV);
- root.appendChild(parent);
- parent.style.fontSize = '2em';
- parent.style.display = 'none';
- if (goog.userAgent.IE || goog.userAgent.GECKO) {
- parent.appendChild(goog.dom.createTextNode('NonWebKitText'));
- }
-
- if (tag1) {
- var e1 = goog.dom.createDom(tag1);
- parent.appendChild(e1);
- parent = e1;
- }
- if (tag2) {
- parent.appendChild(goog.dom.createDom(tag2));
- }
- parent.appendChild(goog.dom.createTextNode('Text'));
- if (goog.userAgent.WEBKIT) {
- root.firstChild.appendChild(goog.dom.createTextNode('WebKitText'));
- }
- }
-
- function testAssertHtmlMatches() {
- setUpAssertHtmlMatches();
-
- helper.assertHtmlMatches('<div style="display: none; font-size: 2em">' +
- '[[IE GECKO]]NonWebKitText<div class="IE"><p class="WEBKIT">' +
- '<span class="GECKO"><br class="GECKO WEBKIT">Text</span></p></div>' +
- '</div>[[WEBKIT]]WebKitText');
- }
-
- function testAssertHtmlMismatchText() {
- setUpAssertHtmlMatches();
-
- var e = assertThrows('Should fail due to mismatched text', function() {
- helper.assertHtmlMatches('<div style="display: none; font-size: 2em">' +
- '[[IE GECKO]]NonWebKitText<div class="IE"><p class="WEBKIT">' +
- '<span class="GECKO"><br class="GECKO WEBKIT">Bad</span></p></div>' +
- '</div>[[WEBKIT]]Extra');
- });
- assertContains('Text should match', e.message);
- }
-
- function testAssertHtmlMismatchTag() {
- setUpAssertHtmlMatches();
-
- var e = assertThrows('Should fail due to mismatched tag', function() {
- helper.assertHtmlMatches('<span style="display: none; font-size: 2em">' +
- '[[IE GECKO]]NonWebKitText<div class="IE"><p class="WEBKIT">' +
- '<span class="GECKO"><br class="GECKO WEBKIT">Text</span></p></div>' +
- '</span>[[WEBKIT]]Extra');
- });
- assertContains('Tag names should match', e.message);
- }
-
- function testAssertHtmlMismatchStyle() {
- setUpAssertHtmlMatches();
-
- var e = assertThrows('Should fail due to mismatched style', function() {
- helper.assertHtmlMatches('<div style="display: none; font-size: 3em">' +
- '[[IE GECKO]]NonWebKitText<div class="IE"><p class="WEBKIT">' +
- '<span class="GECKO"><br class="GECKO WEBKIT">Text</span></p></div>' +
- '</div>[[WEBKIT]]Extra');
- });
- assertContains('Should have same styles', e.message);
- }
-
- function testAssertHtmlMismatchOptionalText() {
- setUpAssertHtmlMatches();
-
- var e = assertThrows('Should fail due to mismatched style', function() {
- helper.assertHtmlMatches('<div style="display: none; font-size: 2em">' +
- '[[IE GECKO]]Bad<div class="IE"><p class="WEBKIT">' +
- '<span class="GECKO"><br class="GECKO WEBKIT">Text</span></p></div>' +
- '</div>[[WEBKIT]]Bad');
- });
- assertContains('Text should match', e.message);
- }
-</script>
-</body>
-</html>