Skip to content

Commit

Permalink
[js] minor tweaks to silence more type warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
jleyba committed Mar 11, 2016
1 parent 0b9d599 commit 981cb1a
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 2 deletions.
23 changes: 23 additions & 0 deletions javascript/node/externs/global.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,29 @@
/** @const */
var global = this;

// DOM type references. Dossier removes DOM externs when type-checking Node
// modules.

/** @constructor */
function Document() {};
/**
* @param {string} tagName .
* @return {!Element} .
*/
Document.prototype.createElement = function(tagName) {};

/** @constructor */
function Element() {}

/** @type {!Document} */Element.prototype.ownerDocument;
/** @type {string} */Element.prototype.innerHTML;
/** @type {string} */Element.prototype.outerHTML;
/** @param {!Element} child . */
Element.prototype.appendChild = function(child) {};
/** @param {boolean} deep . */
Element.prototype.cloneNode = function(deep) {};


// The following will only actually be defined if running with mocha.

/**
Expand Down
2 changes: 1 addition & 1 deletion javascript/node/selenium-webdriver/lib/webdriver.js
Original file line number Diff line number Diff line change
Expand Up @@ -2135,7 +2135,7 @@ class WebElement {
*/
getOuterHtml() {
return this.driver_.executeScript(function() {
var element = arguments[0];
var element = /** @type {!Element} */(arguments[0]);
if ('outerHTML' in element) {
return element.outerHTML;
} else {
Expand Down
16 changes: 15 additions & 1 deletion javascript/node/selenium-webdriver/test/execute_script_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -308,8 +308,22 @@ test.suite(function(env) {
});
});

});
describe('getInnerHtml', function() {
test.it('returns element innerHTML using executeScript', function() {
let html = driver.findElement(By.css('div.request')).getInnerHtml();
assert(html).equalTo('GET /common/echo HTTP/1.1');
});
});

describe('getOuterHtml', function() {
test.it('returns element outerHTML using executeScript', function() {
let html = driver.findElement(By.css('div.request')).getOuterHtml();
assert(html)
.equalTo('<div class="request">GET /common/echo HTTP/1.1</div>');
});
});
});

function verifyJson(expected) {
return function(actual) {
assert(JSON.stringify(actual)).equalTo(JSON.stringify(expected));
Expand Down

0 comments on commit 981cb1a

Please sign in to comment.