| diff --git a/javascript/atoms/dom.js b/javascript/atoms/dom.js |
| index 7dd4e846e4..66b85cdc95 100644 |
| --- a/javascript/atoms/dom.js |
| +++ b/javascript/atoms/dom.js |
| @@ -587,14 +587,8 @@ bot.dom.isShown = function(elem, opt_ignoreOpacity) { |
| var parent = bot.dom.getParentNodeInComposedDom(e); |
| |
| if (bot.dom.IS_SHADOW_DOM_ENABLED && (parent instanceof ShadowRoot)) { |
| - if (parent.host.shadowRoot !== parent) { |
| - // There is a younger shadow root, which will take precedence over |
| - // the shadow this element is in, thus this element won't be |
| - // displayed. |
| - return false; |
| - } else { |
| - parent = parent.host; |
| - } |
| + // For backward compatibility, treat all shadow roots as shown. |
| + return true; |
| } |
| |
| if (parent && (parent.nodeType == goog.dom.NodeType.DOCUMENT || |
| @@ -609,7 +603,7 @@ bot.dom.isShown = function(elem, opt_ignoreOpacity) { |
| return false; |
| } |
| |
| - return parent && displayed(parent); |
| + return !!parent && displayed(parent); |
| } |
| |
| return bot.dom.isShown_(elem, !!opt_ignoreOpacity, displayed); |
| @@ -1270,13 +1264,6 @@ bot.dom.getOpacityNonIE_ = function(elem) { |
| bot.dom.getParentNodeInComposedDom = function(node) { |
| var /**@type {Node}*/ parent = node.parentNode; |
| |
| - // Shadow DOM v1 |
| - if (parent && parent.shadowRoot && node.assignedSlot !== undefined) { |
| - // Can be null on purpose, meaning it has no parent as |
| - // it hasn't yet been slotted |
| - return node.assignedSlot ? node.assignedSlot.parentNode : null; |
| - } |
| - |
| // Shadow DOM V0 (deprecated) |
| if (node.getDestinationInsertionPoints) { |
| var destinations = node.getDestinationInsertionPoints(); |
| @@ -1285,6 +1272,13 @@ bot.dom.getParentNodeInComposedDom = function(node) { |
| } |
| } |
| |
| + // Shadow DOM v1 |
| + if (parent && parent.shadowRoot && node.assignedSlot !== undefined) { |
| + // Can be null on purpose, meaning it has no parent as |
| + // it hasn't yet been slotted |
| + return node.assignedSlot ? node.assignedSlot.parentNode : null; |
| + } |
| + |
| return parent; |
| }; |
| |
| diff --git a/javascript/atoms/mouse.js b/javascript/atoms/mouse.js |
| index 737ed50f62..1bc9e858f5 100644 |
| --- a/javascript/atoms/mouse.js |
| +++ b/javascript/atoms/mouse.js |
| @@ -143,7 +143,7 @@ bot.Mouse.NO_BUTTON_VALUE_INDEX_ = 3; |
| * click/ mouseup/ mouseout/ mousemove contextmenu |
| * dblclick mousedown mouseover |
| * IE_DOC_PRE9 0 0 0 X 1 4 2 X 0 0 0 0 1 4 2 0 X X 0 X |
| - * WEBKIT/IE9 0 1 2 X 0 1 2 X 0 1 2 0 0 1 2 0 X X 2 X |
| + * WEBKIT/IE9 0 1 2 X 0 1 2 X 0 1 2 4 0 1 2 4 X X 2 X |
| * GECKO 0 1 2 X 0 1 2 X 0 0 0 0 0 0 0 0 X X 2 X |
| * </pre> |
| * @private {!Object.<bot.events.EventType, !Array.<?number>>} |
| @@ -163,8 +163,8 @@ bot.Mouse.MOUSE_BUTTON_VALUE_MAP_ = (function() { |
| buttonValueMap[bot.events.EventType.CLICK] = [0, 1, 2, null]; |
| buttonValueMap[bot.events.EventType.CONTEXTMENU] = [null, null, 2, null]; |
| buttonValueMap[bot.events.EventType.MOUSEUP] = [0, 1, 2, null]; |
| - buttonValueMap[bot.events.EventType.MOUSEOUT] = [0, 1, 2, 0]; |
| - buttonValueMap[bot.events.EventType.MOUSEMOVE] = [0, 1, 2, 0]; |
| + buttonValueMap[bot.events.EventType.MOUSEOUT] = [0, 1, 2, 4]; |
| + buttonValueMap[bot.events.EventType.MOUSEMOVE] = [0, 1, 2, 4]; |
| } else { |
| buttonValueMap[bot.events.EventType.CLICK] = [0, 1, 2, null]; |
| buttonValueMap[bot.events.EventType.CONTEXTMENU] = [null, null, 2, null]; |
| diff --git a/javascript/chrome-driver/BUILD.bazel b/javascript/chrome-driver/BUILD.bazel |
| index 9e33cc769e..c231b8e7fd 100644 |
| --- a/javascript/chrome-driver/BUILD.bazel |
| +++ b/javascript/chrome-driver/BUILD.bazel |
| @@ -109,6 +109,7 @@ closure_lang_file( |
| name = "header", |
| out = "atoms.h", |
| lang = "hdecl", |
| + utf8 = True, |
| deps = ATOMS, |
| ) |
| |
| @@ -116,6 +117,7 @@ closure_lang_file( |
| name = "source", |
| out = "atoms.cc", |
| lang = "cc", |
| + utf8 = True, |
| deps = ATOMS, |
| ) |
| |
| diff --git a/javascript/chrome-driver/atoms.js b/javascript/chrome-driver/atoms.js |
| index 5185e010fb..3febbeba5c 100644 |
| --- a/javascript/chrome-driver/atoms.js |
| +++ b/javascript/chrome-driver/atoms.js |
| @@ -211,7 +211,7 @@ webdriver.chrome.getFirstClientRect = function(elem) { |
| * at the given location. Useful for debugging test clicking issues. |
| * |
| * @param {!Element} elem The element to use. |
| - * @param {!goog.math.Coordinate} coord The coordinate to use. |
| + * @param {!Object} coord The coordinate to use. |
| * @return {{clickable:boolean, message: (string|undefined)}} Object containing |
| * a boolean "clickable" property, as to whether it can be clicked, and an |
| * optional "message" string property, which contains any warning/error |
| diff --git a/javascript/private/gen_file.py b/javascript/private/gen_file.py |
| index 27c9fd3236..b37ccbfeff 100644 |
| --- a/javascript/private/gen_file.py |
| +++ b/javascript/private/gen_file.py |
| @@ -33,6 +33,9 @@ def write_atom_literal(out, name, contents, lang): |
| contents = contents.replace('"', '\\"') |
| |
| if "cc" == lang or "hh" == lang: |
| + if utf8: |
| + line_format = " \"{}\",\n" |
| + else: |
| line_format = " L\"{}\",\n" |
| elif "java" == lang: |
| line_format = " .append\(\"{}\")\n" |
| @@ -42,7 +45,9 @@ def write_atom_literal(out, name, contents, lang): |
| name = get_atom_name(name) |
| |
| if "cc" == lang or "hh" == lang: |
| - out.write("const wchar_t* const %s[] = {\n" % name) |
| + string_type = "std::string" if utf8 else "std::wstring" |
| + char_type = "char" if utf8 else "wchar_t" |
| + out.write("const %s* const %s[] = {\n" % (char_type, name)) |
| elif "java" == lang: |
| out.write(" %s(new StringBuilder()\n" % name) |
| else: |
| @@ -69,30 +74,31 @@ def write_atom_literal(out, name, contents, lang): |
| |
| def generate_header(file_name, out, js_map, just_declare): |
| define_guard = "WEBDRIVER_%s" % os.path.basename(file_name.upper()).replace(".", "_") |
| + include_stddef = "" if utf8 else "\n#include <stddef.h> // For wchar_t." |
| |
| out.write("""%s |
| |
| /* AUTO GENERATED - DO NOT EDIT BY HAND */ |
| #ifndef %s |
| #define %s |
| - |
| -#include <stddef.h> // For wchar_t. |
| +%s |
| #include <string> // For std::(w)string. |
| |
| namespace webdriver { |
| namespace atoms { |
| |
| -""" % (_copyright, define_guard, define_guard)) |
| +""" % (_copyright, define_guard, define_guard, include_stddef)) |
| + |
| + string_type = "std::string" if utf8 else "std::wstring" |
| + char_type = "char" if utf8 else "wchar_t" |
| |
| for (name, file) in js_map.items(): |
| if just_declare: |
| - out.write("extern const wchat_t* const %s[];\n" % name.upper()) |
| + out.write("extern const %s* const %s[];\n" % (char_type, name.upper())) |
| else: |
| contents = open(file, "r").read() |
| write_atom_literal(out, name, contents, "hh") |
| |
| - string_type = "std::wstring" |
| - char_type = "wchar_t" |
| out.write(""" |
| static inline %s asString(const %s* const atom[]) { |
| %s source; |
| @@ -168,14 +174,17 @@ public enum %s { |
| } |
| """ % class_name) |
| |
| +utf8 = False |
| |
| def main(argv=[]): |
| lang = argv[1] |
| file_name = argv[2] |
| preamble = argv[3] |
| + global utf8 |
| + utf8 = (argv[4] == "true") |
| |
| js_map = {} |
| - for i in range(4, len(argv), 2): |
| + for i in range(5, len(argv), 2): |
| js_map[argv[i]] = argv[i + 1] |
| |
| with open(file_name, "w") as out: |
| diff --git a/javascript/private/header.bzl b/javascript/private/header.bzl |
| index ced4059a3d..754879bb1f 100644 |
| --- a/javascript/private/header.bzl |
| +++ b/javascript/private/header.bzl |
| @@ -22,6 +22,7 @@ def _closure_lang_file_impl(ctx): |
| args.add(ctx.attr.lang) |
| args.add(ctx.outputs.out) |
| args.add(ctx.attr.preamble) |
| + args.add(ctx.attr.utf8) |
| for key in sorted(binaries.keys()): |
| args.add(key) |
| args.add(binaries[key]) |
| @@ -59,5 +60,10 @@ closure_lang_file = rule( |
| executable = True, |
| cfg = "host", |
| ), |
| + "utf8": attr.bool( |
| + doc = "Generate utf8 or not. True will generate string and char." |
| + "False, will generate wchar_t and wstring. Defaults to False", |
| + default = False, |
| + ), |
| }, |
| ) |