Update wmts-hidpi, add nicer-api-docs
This commit is contained in:
@@ -0,0 +1,293 @@
|
||||
// Copyright 2009 The Closure Library Authors. All Rights Reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS-IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
/**
|
||||
* @fileoverview Testing utilities for editor specific DOM related tests.
|
||||
*
|
||||
*/
|
||||
|
||||
goog.provide('goog.testing.editor.dom');
|
||||
|
||||
goog.require('goog.dom.NodeType');
|
||||
goog.require('goog.dom.TagIterator');
|
||||
goog.require('goog.dom.TagWalkType');
|
||||
goog.require('goog.iter');
|
||||
goog.require('goog.string');
|
||||
goog.require('goog.testing.asserts');
|
||||
|
||||
|
||||
/**
|
||||
* Returns the previous (in document order) node from the given node that is a
|
||||
* non-empty text node, or null if none is found or opt_stopAt is not an
|
||||
* ancestor of node. Note that if the given node has children, the search will
|
||||
* start from the end tag of the node, meaning all its descendants will be
|
||||
* included in the search, unless opt_skipDescendants is true.
|
||||
* @param {Node} node Node to start searching from.
|
||||
* @param {Node=} opt_stopAt Node to stop searching at (search will be
|
||||
* restricted to this node's subtree), defaults to the body of the document
|
||||
* containing node.
|
||||
* @param {boolean=} opt_skipDescendants Whether to skip searching the given
|
||||
* node's descentants.
|
||||
* @return {Text} The previous (in document order) node from the given node
|
||||
* that is a non-empty text node, or null if none is found.
|
||||
*/
|
||||
goog.testing.editor.dom.getPreviousNonEmptyTextNode = function(
|
||||
node, opt_stopAt, opt_skipDescendants) {
|
||||
return goog.testing.editor.dom.getPreviousNextNonEmptyTextNodeHelper_(
|
||||
node, opt_stopAt, opt_skipDescendants, true);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Returns the next (in document order) node from the given node that is a
|
||||
* non-empty text node, or null if none is found or opt_stopAt is not an
|
||||
* ancestor of node. Note that if the given node has children, the search will
|
||||
* start from the start tag of the node, meaning all its descendants will be
|
||||
* included in the search, unless opt_skipDescendants is true.
|
||||
* @param {Node} node Node to start searching from.
|
||||
* @param {Node=} opt_stopAt Node to stop searching at (search will be
|
||||
* restricted to this node's subtree), defaults to the body of the document
|
||||
* containing node.
|
||||
* @param {boolean=} opt_skipDescendants Whether to skip searching the given
|
||||
* node's descentants.
|
||||
* @return {Text} The next (in document order) node from the given node that
|
||||
* is a non-empty text node, or null if none is found or opt_stopAt is not
|
||||
* an ancestor of node.
|
||||
*/
|
||||
goog.testing.editor.dom.getNextNonEmptyTextNode = function(
|
||||
node, opt_stopAt, opt_skipDescendants) {
|
||||
return goog.testing.editor.dom.getPreviousNextNonEmptyTextNodeHelper_(
|
||||
node, opt_stopAt, opt_skipDescendants, false);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Helper that returns the previous or next (in document order) node from the
|
||||
* given node that is a non-empty text node, or null if none is found or
|
||||
* opt_stopAt is not an ancestor of node. Note that if the given node has
|
||||
* children, the search will start from the end or start tag of the node
|
||||
* (depending on whether it's searching for the previous or next node), meaning
|
||||
* all its descendants will be included in the search, unless
|
||||
* opt_skipDescendants is true.
|
||||
* @param {Node} node Node to start searching from.
|
||||
* @param {Node=} opt_stopAt Node to stop searching at (search will be
|
||||
* restricted to this node's subtree), defaults to the body of the document
|
||||
* containing node.
|
||||
* @param {boolean=} opt_skipDescendants Whether to skip searching the given
|
||||
* node's descentants.
|
||||
* @param {boolean=} opt_isPrevious Whether to search for the previous non-empty
|
||||
* text node instead of the next one.
|
||||
* @return {Text} The next (in document order) node from the given node that
|
||||
* is a non-empty text node, or null if none is found or opt_stopAt is not
|
||||
* an ancestor of node.
|
||||
* @private
|
||||
*/
|
||||
goog.testing.editor.dom.getPreviousNextNonEmptyTextNodeHelper_ = function(
|
||||
node, opt_stopAt, opt_skipDescendants, opt_isPrevious) {
|
||||
opt_stopAt = opt_stopAt || node.ownerDocument.body;
|
||||
// Initializing the iterator to iterate over the children of opt_stopAt
|
||||
// makes it stop only when it finishes iterating through all of that
|
||||
// node's children, even though we will start at a different node and exit
|
||||
// that starting node's subtree in the process.
|
||||
var iter = new goog.dom.TagIterator(opt_stopAt, opt_isPrevious);
|
||||
|
||||
// TODO(user): Move this logic to a new method in TagIterator such as
|
||||
// skipToNode().
|
||||
// Then we set the iterator to start at the given start node, not opt_stopAt.
|
||||
var walkType; // Let TagIterator set the initial walk type by default.
|
||||
var depth = goog.testing.editor.dom.getRelativeDepth_(node, opt_stopAt);
|
||||
if (depth == -1) {
|
||||
return null; // Fail because opt_stopAt is not an ancestor of node.
|
||||
}
|
||||
if (node.nodeType == goog.dom.NodeType.ELEMENT) {
|
||||
if (opt_skipDescendants) {
|
||||
// Specifically set the initial walk type so that we skip the descendant
|
||||
// subtree by starting at the start if going backwards or at the end if
|
||||
// going forwards.
|
||||
walkType = opt_isPrevious ? goog.dom.TagWalkType.START_TAG :
|
||||
goog.dom.TagWalkType.END_TAG;
|
||||
} else {
|
||||
// We're starting "inside" an element node so the depth needs to be one
|
||||
// deeper than the node's actual depth. That's how TagIterator works!
|
||||
depth++;
|
||||
}
|
||||
}
|
||||
iter.setPosition(node, walkType, depth);
|
||||
|
||||
// Advance the iterator so it skips the start node.
|
||||
try {
|
||||
iter.next();
|
||||
} catch (e) {
|
||||
return null; // It could have been a leaf node.
|
||||
}
|
||||
// Now just get the first non-empty text node the iterator finds.
|
||||
var filter = goog.iter.filter(iter,
|
||||
goog.testing.editor.dom.isNonEmptyTextNode_);
|
||||
try {
|
||||
return /** @type {Text} */ (filter.next());
|
||||
} catch (e) { // No next item is available so return null.
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Returns whether the given node is a non-empty text node.
|
||||
* @param {Node} node Node to be checked.
|
||||
* @return {boolean} Whether the given node is a non-empty text node.
|
||||
* @private
|
||||
*/
|
||||
goog.testing.editor.dom.isNonEmptyTextNode_ = function(node) {
|
||||
return !!node && node.nodeType == goog.dom.NodeType.TEXT && node.length > 0;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Returns the depth of the given node relative to the given parent node, or -1
|
||||
* if the given node is not a descendant of the given parent node. E.g. if
|
||||
* node == parentNode returns 0, if node.parentNode == parentNode returns 1,
|
||||
* etc.
|
||||
* @param {Node} node Node whose depth to get.
|
||||
* @param {Node} parentNode Node relative to which the depth should be
|
||||
* calculated.
|
||||
* @return {number} The depth of the given node relative to the given parent
|
||||
* node, or -1 if the given node is not a descendant of the given parent
|
||||
* node.
|
||||
* @private
|
||||
*/
|
||||
goog.testing.editor.dom.getRelativeDepth_ = function(node, parentNode) {
|
||||
var depth = 0;
|
||||
while (node) {
|
||||
if (node == parentNode) {
|
||||
return depth;
|
||||
}
|
||||
node = node.parentNode;
|
||||
depth++;
|
||||
}
|
||||
return -1;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Assert that the range is surrounded by the given strings. This is useful
|
||||
* because different browsers can place the range endpoints inside different
|
||||
* nodes even when visually the range looks the same. Also, there may be empty
|
||||
* text nodes in the way (again depending on the browser) making it difficult to
|
||||
* use assertRangeEquals.
|
||||
* @param {string} before String that should occur immediately before the start
|
||||
* point of the range. If this is the empty string, assert will only succeed
|
||||
* if there is no text before the start point of the range.
|
||||
* @param {string} after String that should occur immediately after the end
|
||||
* point of the range. If this is the empty string, assert will only succeed
|
||||
* if there is no text after the end point of the range.
|
||||
* @param {goog.dom.AbstractRange} range The range to be tested.
|
||||
* @param {Node=} opt_stopAt Node to stop searching at (search will be
|
||||
* restricted to this node's subtree).
|
||||
*/
|
||||
goog.testing.editor.dom.assertRangeBetweenText = function(before,
|
||||
after,
|
||||
range,
|
||||
opt_stopAt) {
|
||||
var previousText =
|
||||
goog.testing.editor.dom.getTextFollowingRange_(range, true, opt_stopAt);
|
||||
if (before == '') {
|
||||
assertNull('Expected nothing before range but found <' + previousText + '>',
|
||||
previousText);
|
||||
} else {
|
||||
assertNotNull('Expected <' + before + '> before range but found nothing',
|
||||
previousText);
|
||||
assertTrue('Expected <' + before + '> before range but found <' +
|
||||
previousText + '>',
|
||||
goog.string.endsWith(
|
||||
/** @type {string} */ (previousText), before));
|
||||
}
|
||||
var nextText =
|
||||
goog.testing.editor.dom.getTextFollowingRange_(range, false, opt_stopAt);
|
||||
if (after == '') {
|
||||
assertNull('Expected nothing after range but found <' + nextText + '>',
|
||||
nextText);
|
||||
} else {
|
||||
assertNotNull('Expected <' + after + '> after range but found nothing',
|
||||
nextText);
|
||||
assertTrue('Expected <' + after + '> after range but found <' +
|
||||
nextText + '>',
|
||||
goog.string.startsWith(
|
||||
/** @type {string} */ (nextText), after));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Returns the text that follows the given range, where the term "follows" means
|
||||
* "comes immediately before the start of the range" if isBefore is true, and
|
||||
* "comes immediately after the end of the range" if isBefore is false, or null
|
||||
* if no non-empty text node is found.
|
||||
* @param {goog.dom.AbstractRange} range The range to search from.
|
||||
* @param {boolean} isBefore Whether to search before the range instead of
|
||||
* after it.
|
||||
* @param {Node=} opt_stopAt Node to stop searching at (search will be
|
||||
* restricted to this node's subtree).
|
||||
* @return {?string} The text that follows the given range, or null if no
|
||||
* non-empty text node is found.
|
||||
* @private
|
||||
*/
|
||||
goog.testing.editor.dom.getTextFollowingRange_ = function(range,
|
||||
isBefore,
|
||||
opt_stopAt) {
|
||||
var followingTextNode;
|
||||
var endpointNode = isBefore ? range.getStartNode() : range.getEndNode();
|
||||
var endpointOffset = isBefore ? range.getStartOffset() : range.getEndOffset();
|
||||
var getFollowingTextNode =
|
||||
isBefore ? goog.testing.editor.dom.getPreviousNonEmptyTextNode :
|
||||
goog.testing.editor.dom.getNextNonEmptyTextNode;
|
||||
|
||||
if (endpointNode.nodeType == goog.dom.NodeType.TEXT) {
|
||||
// Range endpoint is in a text node.
|
||||
var endText = endpointNode.nodeValue;
|
||||
if (isBefore ? endpointOffset > 0 : endpointOffset < endText.length) {
|
||||
// There is text in this node following the endpoint so return the portion
|
||||
// that follows the endpoint.
|
||||
return isBefore ? endText.substr(0, endpointOffset) :
|
||||
endText.substr(endpointOffset);
|
||||
} else {
|
||||
// There is no text following the endpoint so look for the follwing text
|
||||
// node.
|
||||
followingTextNode = getFollowingTextNode(endpointNode, opt_stopAt);
|
||||
return followingTextNode && followingTextNode.nodeValue;
|
||||
}
|
||||
} else {
|
||||
// Range endpoint is in an element node.
|
||||
var numChildren = endpointNode.childNodes.length;
|
||||
if (isBefore ? endpointOffset > 0 : endpointOffset < numChildren) {
|
||||
// There is at least one child following the endpoint.
|
||||
var followingChild =
|
||||
endpointNode.childNodes[isBefore ? endpointOffset - 1 :
|
||||
endpointOffset];
|
||||
if (goog.testing.editor.dom.isNonEmptyTextNode_(followingChild)) {
|
||||
// The following child has text so return that.
|
||||
return followingChild.nodeValue;
|
||||
} else {
|
||||
// The following child has no text so look for the following text node.
|
||||
followingTextNode = getFollowingTextNode(followingChild, opt_stopAt);
|
||||
return followingTextNode && followingTextNode.nodeValue;
|
||||
}
|
||||
} else {
|
||||
// There is no child following the endpoint, so search from the endpoint
|
||||
// node, but don't search its children because they are not following the
|
||||
// endpoint!
|
||||
followingTextNode = getFollowingTextNode(endpointNode, opt_stopAt, true);
|
||||
return followingTextNode && followingTextNode.nodeValue;
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,99 @@
|
||||
// Copyright 2008 The Closure Library Authors. All Rights Reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS-IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
/**
|
||||
* @fileoverview Mock of goog.editor.field.
|
||||
*
|
||||
* @author robbyw@google.com (Robby Walker)
|
||||
*/
|
||||
|
||||
goog.provide('goog.testing.editor.FieldMock');
|
||||
|
||||
goog.require('goog.dom');
|
||||
goog.require('goog.dom.Range');
|
||||
goog.require('goog.editor.Field');
|
||||
goog.require('goog.testing.LooseMock');
|
||||
goog.require('goog.testing.mockmatchers');
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Mock of goog.editor.Field.
|
||||
* @param {Window=} opt_window Window the field would edit. Defaults to
|
||||
* {@code window}.
|
||||
* @param {Window=} opt_appWindow "AppWindow" of the field, which can be
|
||||
* different from {@code opt_window} when mocking a field that uses an
|
||||
* iframe. Defaults to {@code opt_window}.
|
||||
* @param {goog.dom.AbstractRange=} opt_range An object (mock or real) to be
|
||||
* returned by getRange(). If ommitted, a new goog.dom.Range is created
|
||||
* from the window every time getRange() is called.
|
||||
* @constructor
|
||||
* @extends {goog.testing.LooseMock}
|
||||
* @suppress {missingProperties} Mocks do not fit in the type system well.
|
||||
*/
|
||||
goog.testing.editor.FieldMock =
|
||||
function(opt_window, opt_appWindow, opt_range) {
|
||||
goog.testing.LooseMock.call(this, goog.editor.Field);
|
||||
opt_window = opt_window || window;
|
||||
opt_appWindow = opt_appWindow || opt_window;
|
||||
|
||||
this.getAppWindow();
|
||||
this.$anyTimes();
|
||||
this.$returns(opt_appWindow);
|
||||
|
||||
this.getRange();
|
||||
this.$anyTimes();
|
||||
this.$does(function() {
|
||||
return opt_range || goog.dom.Range.createFromWindow(opt_window);
|
||||
});
|
||||
|
||||
this.getEditableDomHelper();
|
||||
this.$anyTimes();
|
||||
this.$returns(goog.dom.getDomHelper(opt_window.document));
|
||||
|
||||
this.usesIframe();
|
||||
this.$anyTimes();
|
||||
|
||||
this.getBaseZindex();
|
||||
this.$anyTimes();
|
||||
this.$returns(0);
|
||||
|
||||
this.restoreSavedRange(goog.testing.mockmatchers.ignoreArgument);
|
||||
this.$anyTimes();
|
||||
this.$does(function(range) {
|
||||
if (range) {
|
||||
range.restore();
|
||||
}
|
||||
this.focus();
|
||||
});
|
||||
|
||||
// These methods cannot be set on the prototype, because the prototype
|
||||
// gets stepped on by the mock framework.
|
||||
var inModalMode = false;
|
||||
|
||||
/**
|
||||
* @return {boolean} Whether we're in modal interaction mode.
|
||||
*/
|
||||
this.inModalMode = function() {
|
||||
return inModalMode;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {boolean} mode Sets whether we're in modal interaction mode.
|
||||
*/
|
||||
this.setModalMode = function(mode) {
|
||||
inModalMode = mode;
|
||||
};
|
||||
};
|
||||
goog.inherits(goog.testing.editor.FieldMock, goog.testing.LooseMock);
|
||||
@@ -0,0 +1,176 @@
|
||||
// Copyright 2008 The Closure Library Authors. All Rights Reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS-IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
/**
|
||||
* @fileoverview Class that allows for simple text editing tests.
|
||||
*
|
||||
* @author robbyw@google.com (Robby Walker)
|
||||
*/
|
||||
|
||||
goog.provide('goog.testing.editor.TestHelper');
|
||||
|
||||
goog.require('goog.Disposable');
|
||||
goog.require('goog.dom');
|
||||
goog.require('goog.dom.Range');
|
||||
goog.require('goog.editor.BrowserFeature');
|
||||
goog.require('goog.editor.node');
|
||||
goog.require('goog.editor.plugins.AbstractBubblePlugin');
|
||||
goog.require('goog.testing.dom');
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Create a new test controller.
|
||||
* @param {Element} root The root editable element.
|
||||
* @constructor
|
||||
* @extends {goog.Disposable}
|
||||
*/
|
||||
goog.testing.editor.TestHelper = function(root) {
|
||||
if (!root) {
|
||||
throw Error('Null root');
|
||||
}
|
||||
goog.Disposable.call(this);
|
||||
|
||||
/**
|
||||
* Convenience variable for root DOM element.
|
||||
* @type {!Element}
|
||||
* @private
|
||||
*/
|
||||
this.root_ = root;
|
||||
|
||||
/**
|
||||
* The starting HTML of the editable element.
|
||||
* @type {string}
|
||||
* @private
|
||||
*/
|
||||
this.savedHtml_ = '';
|
||||
};
|
||||
goog.inherits(goog.testing.editor.TestHelper, goog.Disposable);
|
||||
|
||||
|
||||
/**
|
||||
* Selects a new root element.
|
||||
* @param {Element} root The root editable element.
|
||||
*/
|
||||
goog.testing.editor.TestHelper.prototype.setRoot = function(root) {
|
||||
if (!root) {
|
||||
throw Error('Null root');
|
||||
}
|
||||
this.root_ = root;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Make the root element editable. Alse saves its HTML to be restored
|
||||
* in tearDown.
|
||||
*/
|
||||
goog.testing.editor.TestHelper.prototype.setUpEditableElement = function() {
|
||||
this.savedHtml_ = this.root_.innerHTML;
|
||||
if (goog.editor.BrowserFeature.HAS_CONTENT_EDITABLE) {
|
||||
this.root_.contentEditable = true;
|
||||
} else {
|
||||
this.root_.ownerDocument.designMode = 'on';
|
||||
}
|
||||
this.root_.setAttribute('g_editable', 'true');
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Reset the element previously initialized, restoring its HTML and making it
|
||||
* non editable.
|
||||
*/
|
||||
goog.testing.editor.TestHelper.prototype.tearDownEditableElement = function() {
|
||||
if (goog.editor.BrowserFeature.HAS_CONTENT_EDITABLE) {
|
||||
this.root_.contentEditable = false;
|
||||
} else {
|
||||
this.root_.ownerDocument.designMode = 'off';
|
||||
}
|
||||
goog.dom.removeChildren(this.root_);
|
||||
this.root_.innerHTML = this.savedHtml_;
|
||||
this.root_.removeAttribute('g_editable');
|
||||
|
||||
if (goog.editor.plugins && goog.editor.plugins.AbstractBubblePlugin) {
|
||||
// Remove old bubbles.
|
||||
for (var key in goog.editor.plugins.AbstractBubblePlugin.bubbleMap_) {
|
||||
goog.editor.plugins.AbstractBubblePlugin.bubbleMap_[key].dispose();
|
||||
}
|
||||
// Ensure we get a new bubble for each test.
|
||||
goog.editor.plugins.AbstractBubblePlugin.bubbleMap_ = {};
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Assert that the html in 'root' is substantially similar to htmlPattern.
|
||||
* This method tests for the same set of styles, and for the same order of
|
||||
* nodes. Breaking whitespace nodes are ignored. Elements can be annotated
|
||||
* with classnames corresponding to keys in goog.userAgent and will be
|
||||
* expected to show up in that user agent and expected not to show up in
|
||||
* others.
|
||||
* @param {string} htmlPattern The pattern to match.
|
||||
*/
|
||||
goog.testing.editor.TestHelper.prototype.assertHtmlMatches = function(
|
||||
htmlPattern) {
|
||||
goog.testing.dom.assertHtmlContentsMatch(htmlPattern, this.root_);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Finds the first text node descendant of root with the given content.
|
||||
* @param {string|RegExp} textOrRegexp The text to find, or a regular
|
||||
* expression to find a match of.
|
||||
* @return {Node} The first text node that matches, or null if none is found.
|
||||
*/
|
||||
goog.testing.editor.TestHelper.prototype.findTextNode = function(textOrRegexp) {
|
||||
return goog.testing.dom.findTextNode(textOrRegexp, this.root_);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Select from the given from offset in the given from node to the given
|
||||
* to offset in the optionally given to node. If nodes are passed in, uses them,
|
||||
* otherwise uses findTextNode to find the nodes to select. Selects a caret
|
||||
* if opt_to and opt_toOffset are not given.
|
||||
* @param {Node|string} from Node or text of the node to start the selection at.
|
||||
* @param {number} fromOffset Offset within the above node to start the
|
||||
* selection at.
|
||||
* @param {Node|string=} opt_to Node or text of the node to end the selection
|
||||
* at.
|
||||
* @param {number=} opt_toOffset Offset within the above node to end the
|
||||
* selection at.
|
||||
*/
|
||||
goog.testing.editor.TestHelper.prototype.select = function(from, fromOffset,
|
||||
opt_to, opt_toOffset) {
|
||||
var end;
|
||||
var start = end = goog.isString(from) ? this.findTextNode(from) : from;
|
||||
var endOffset;
|
||||
var startOffset = endOffset = fromOffset;
|
||||
|
||||
if (opt_to && goog.isNumber(opt_toOffset)) {
|
||||
end = goog.isString(opt_to) ? this.findTextNode(opt_to) : opt_to;
|
||||
endOffset = opt_toOffset;
|
||||
}
|
||||
|
||||
goog.dom.Range.createFromNodes(start, startOffset, end, endOffset).select();
|
||||
};
|
||||
|
||||
|
||||
/** @override */
|
||||
goog.testing.editor.TestHelper.prototype.disposeInternal = function() {
|
||||
if (goog.editor.node.isEditableContainer(this.root_)) {
|
||||
this.tearDownEditableElement();
|
||||
}
|
||||
delete this.root_;
|
||||
goog.base(this, 'disposeInternal');
|
||||
};
|
||||
Reference in New Issue
Block a user