/***************************************************************************** * * Copyright (c) 2003-2005 Kupu Contributors. All rights reserved. * * This software is distributed under the terms of the Kupu * License. See LICENSE.txt for license text. For a list of Kupu * Contributors see CREDITS.txt. * *****************************************************************************/ // $Id$ function InitKupuCheckersTestCase() { this.name = 'InitKupuCheckersTestCase'; // Please note that we are cheating here a bit: // 1. No idea how to get the real checkers without setting up a complete // Kupu, so we work on a copy here. // 2. We test parentElement, parentWithStyleChecker and the arguments // used in initKupu simultanously, so these tests don't tell you what's // responsible if they fail. /*Moz: foo bar baz spam eggs Moz noCSS: foo bar baz spam eggs IE: foo bar baz spam eggs*/ SelectionTestCase.apply(this); this.base_setUp = this.setUp; this._makeBoldchecker = function() { // XXX copied from initKupu, must be synced manually! var boldchecker = parentWithStyleChecker(['b', 'strong'], 'fontWeight', 'bold', 'bold'); return boldchecker; }; this._makeItalicschecker = function() { // XXX copied from initKupu, must be synced manually! var italicschecker = parentWithStyleChecker(['i', 'em'], 'fontStyle', 'italic', 'italic'); return italicschecker; }; this._makeUnderlinechecker = function() { // XXX copied from initKupu, must be synced manually! var underlinechecker = parentWithStyleChecker(['u'], 'textDecoration', 'underline', 'underline'); return underlinechecker; }; this.setUp = function() { this.base_setUp(); this.editor = new KupuEditor(this.kupudoc, {}, null); }; this.testBoldcheckerBold = function() { this.body.innerHTML = '
foo bar
'; // select |ar| this._setSelection(5, null, 7, false, 'ar'); var selNode = this.selection.parentElement(); var boldchecker = this._makeBoldchecker(); this.assertEquals(boldchecker(selNode, null, this.editor), true); }; this.testBoldcheckerMixed = function() { this.body.innerHTML = 'foo bar
'; // select |o bar| this._setSelection(2, null, 7, false, 'o bar'); var selNode = this.selection.parentElement(); var boldchecker = this._makeBoldchecker(); this.assertEquals(boldchecker(selNode, null, this.editor), false); }; opera_is_broken(this, 'testBoldcheckerMixed'); this.testBoldcheckerBoldLeftOuter = function() { this.body.innerHTML = 'foo bar
'; // select |bar| this._setSelection(4, false, 7, false, 'bar'); var selNode = this.selection.parentElement(); var boldchecker = this._makeBoldchecker(); this.assertEquals(boldchecker(selNode, null, this.editor), true); }; opera_is_broken(this, 'testBoldcheckerBoldLeftOuter'); this.testBoldcheckerBoldInner = function() { this.body.innerHTML = 'foo bar
'; // select |bar| this._setSelection(4, true, 7, false, 'bar'); var selNode = this.selection.parentElement(); var boldchecker = this._makeBoldchecker(); this.assertEquals(boldchecker(selNode, null, this.editor), true); }; opera_is_broken(this, 'testBoldcheckerBoldInner'); this.testBoldcheckerExecCommand = function() { this.body.innerHTML = 'foo bar
'; // select |bar| this._setSelection(4, true, 7, false, 'bar'); this.doc.execCommand('bold', null, null); var selNode = this.selection.parentElement(); var boldchecker = this._makeBoldchecker(); this.assertEquals(boldchecker(selNode, null, this.editor), true); }; this.testBoldcheckerExecCommandCollapsed = function() { // XXX: the feature seems to work, but test is broken on IE this.body.innerHTML = 'foo bar
'; // select || this._setSelection(3, null, 3, null, ''); this.doc.execCommand('bold', null, null); var selNode = this.selection.parentElement(); var boldchecker = this._makeBoldchecker(); this.assertEquals(boldchecker(selNode, null, this.editor), true); }; opera_is_broken(this, 'testBoldcheckerExecCommandCollapsed'); ie_is_broken(this, 'testBoldcheckerExecCommandCollapsed'); this.testBoldcheckerExecCommandNoCSS = function() { this.editor.getDocument().execCommand('styleWithCSS', null, false); this.body.innerHTML = 'foo bar
'; // select |bar| this._setSelection(4, null, 7, false, 'bar'); this.editor.getDocument().execCommand('bold', null, null); var selNode = this.selection.parentElement(); var boldchecker = this._makeBoldchecker(); this.assertEquals(boldchecker(selNode, null, this.editor), true); this.editor.getDocument().execCommand('styleWithCSS', null, true); }; ie_is_broken(this, 'testBoldcheckerExecCommandNoCSS'); this.testBoldcheckerStrong = function() { this.body.innerHTML = 'foo bar
'; // select |ar| this._setSelection(5, null, 7, false, 'ar'); var selNode = this.selection.parentElement(); var boldchecker = this._makeBoldchecker(); this.assertEquals(boldchecker(selNode, null, this.editor), true); }; this.testBoldcheckerStyle = function() { this.body.innerHTML = 'foo bar
'; // select |ar| this._setSelection(5, null, 7, false, 'ar'); var selNode = this.selection.parentElement(); var boldchecker = this._makeBoldchecker(); this.assertEquals(boldchecker(selNode, null, this.editor), true); }; opera_is_broken(this, 'testBoldcheckerStyle'); this.testItalicscheckerItalics = function() { this.body.innerHTML = 'foo bar
'; // select |ar| this._setSelection(5, null, 7, false, 'ar'); var selNode = this.selection.parentElement(); var italicschecker = this._makeItalicschecker(); this.assertEquals(italicschecker(selNode, null, this.editor), true); }; this.testItalicscheckerEmphasis = function() { this.body.innerHTML = 'foo bar
'; // select |ar| this._setSelection(5, null, 7, false, 'ar'); var selNode = this.selection.parentElement(); var italicschecker = this._makeItalicschecker(); this.assertEquals(italicschecker(selNode, null, this.editor), true); }; this.testItalicscheckerStyle = function() { this.body.innerHTML = 'foo bar
'; // select |ar| this._setSelection(5, null, 7, false, 'ar'); var selNode = this.selection.parentElement(); var italicschecker = this._makeItalicschecker(); this.assertEquals(italicschecker(selNode, null, this.editor), true); }; this.testUnderlinecheckerStyle = function() { this.body.innerHTML = 'foo bar
'; // select |ar| this._setSelection(5, null, 7, false, 'ar'); var selNode = this.selection.parentElement(); var underlinechecker = this._makeUnderlinechecker(); this.assertEquals(underlinechecker(selNode, null, this.editor), true); }; }; InitKupuCheckersTestCase.prototype = new SelectionTestCase;