From 9b0d80d1b8e18ece4551ba02e0ce27e1d0da9cfc Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Mon, 9 Jan 2017 11:25:34 -0800 Subject: [PATCH] Arrow lookup is ok if it is not followed by "]" because then it has to be function call Fixes #402 --- TypeScript.YAML-tmLanguage | 2 +- TypeScript.tmLanguage | 2 +- TypeScriptReact.tmLanguage | 2 +- tests/baselines/Issue402.baseline.txt | 592 ++++++++++++++++++++++++++ tests/cases/Issue402.ts | 25 ++ 5 files changed, 620 insertions(+), 3 deletions(-) create mode 100644 tests/baselines/Issue402.baseline.txt create mode 100644 tests/cases/Issue402.ts diff --git a/TypeScript.YAML-tmLanguage b/TypeScript.YAML-tmLanguage index 6bebcec6..24da14fb 100644 --- a/TypeScript.YAML-tmLanguage +++ b/TypeScript.YAML-tmLanguage @@ -1595,7 +1595,7 @@ repository: (?: (? is on new line ( diff --git a/TypeScript.tmLanguage b/TypeScript.tmLanguage index 37d27dec..f9b7220d 100644 --- a/TypeScript.tmLanguage +++ b/TypeScript.tmLanguage @@ -4401,7 +4401,7 @@ begin (?x) (?: (?<!\.|\$)(\basync)(?=\s*[<(]) -) | (\s* +) | ((?<!\])\s* (?= # sure shot arrow functions even if => is on new line ( diff --git a/TypeScriptReact.tmLanguage b/TypeScriptReact.tmLanguage index c7b004f1..f9b58266 100644 --- a/TypeScriptReact.tmLanguage +++ b/TypeScriptReact.tmLanguage @@ -4383,7 +4383,7 @@ begin (?x) (?: (?<!\.|\$)(\basync)(?=\s*[<(]) -) | (\s* +) | ((?<!\])\s* (?= # sure shot arrow functions even if => is on new line ( diff --git a/tests/baselines/Issue402.baseline.txt b/tests/baselines/Issue402.baseline.txt new file mode 100644 index 00000000..948f0213 --- /dev/null +++ b/tests/baselines/Issue402.baseline.txt @@ -0,0 +1,592 @@ +original file +----------------------------------- +ipcMain.on('ELECTRON_GUEST_WINDOW_MANAGER_WEB_CONTENTS_METHOD', function (event, guestId, method, ...args) { + const guestContents = webContents.fromId(guestId) + if (guestContents == null) return + + if (canAccessWindow(event.sender, guestContents)) { + guestContents[method](...args) + } else { + console.error(`Blocked ${event.sender.getURL()} from calling ${method} on its opener.`) + } +}) + +ipcMain.on('ELECTRON_GUEST_WINDOW_MANAGER_WEB_CONTENTS_METHOD_SYNC', function (event, guestId, method, ...args) { + const guestContents = webContents.fromId(guestId) + if (guestContents == null) { + event.returnValue = null + return + } + + if (canAccessWindow(event.sender, guestContents)) { + event.returnValue = guestContents[method](...args) + } else { + console.error(`Blocked ${event.sender.getURL()} from calling ${method} on its opener.`) + event.returnValue = null + } +}) +----------------------------------- + +Grammar: TypeScript.tmLanguage +----------------------------------- +>ipcMain.on('ELECTRON_GUEST_WINDOW_MANAGER_WEB_CONTENTS_METHOD', function (event, guestId, method, ...args) { + ^^^^^^^ + source.ts variable.other.object.ts + ^ + source.ts punctuation.accessor.ts + ^^ + source.ts entity.name.function.ts + ^ + source.ts meta.brace.round.ts + ^ + source.ts string.quoted.single.ts punctuation.definition.string.begin.ts + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + source.ts string.quoted.single.ts + ^ + source.ts string.quoted.single.ts punctuation.definition.string.end.ts + ^ + source.ts punctuation.separator.comma.ts + ^ + source.ts + ^^^^^^^^ + source.ts meta.function.expression.ts storage.type.function.ts + ^ + source.ts meta.function.expression.ts + ^ + source.ts meta.function.expression.ts meta.parameters.ts punctuation.definition.parameters.begin.ts + ^^^^^ + source.ts meta.function.expression.ts meta.parameters.ts variable.parameter.ts + ^ + source.ts meta.function.expression.ts meta.parameters.ts punctuation.separator.parameter.ts + ^ + source.ts meta.function.expression.ts meta.parameters.ts + ^^^^^^^ + source.ts meta.function.expression.ts meta.parameters.ts variable.parameter.ts + ^ + source.ts meta.function.expression.ts meta.parameters.ts punctuation.separator.parameter.ts + ^ + source.ts meta.function.expression.ts meta.parameters.ts + ^^^^^^ + source.ts meta.function.expression.ts meta.parameters.ts variable.parameter.ts + ^ + source.ts meta.function.expression.ts meta.parameters.ts punctuation.separator.parameter.ts + ^ + source.ts meta.function.expression.ts meta.parameters.ts + ^^^ + source.ts meta.function.expression.ts meta.parameters.ts keyword.operator.rest.ts + ^^^^ + source.ts meta.function.expression.ts meta.parameters.ts variable.parameter.ts + ^ + source.ts meta.function.expression.ts meta.parameters.ts punctuation.definition.parameters.end.ts + ^ + source.ts meta.function.expression.ts + ^ + source.ts meta.function.expression.ts meta.block.ts punctuation.definition.block.ts + ^^ + source.ts meta.function.expression.ts meta.block.ts +> const guestContents = webContents.fromId(guestId) + ^^ + source.ts meta.function.expression.ts meta.block.ts + ^^^^^ + source.ts meta.function.expression.ts meta.block.ts meta.var.expr.ts storage.type.ts + ^ + source.ts meta.function.expression.ts meta.block.ts meta.var.expr.ts + ^^^^^^^^^^^^^ + source.ts meta.function.expression.ts meta.block.ts meta.var.expr.ts meta.var-single-variable.expr.ts meta.definition.variable.ts variable.other.readwrite.ts + ^ + source.ts meta.function.expression.ts meta.block.ts meta.var.expr.ts meta.var-single-variable.expr.ts + ^ + source.ts meta.function.expression.ts meta.block.ts meta.var.expr.ts keyword.operator.assignment.ts + ^ + source.ts meta.function.expression.ts meta.block.ts meta.var.expr.ts + ^^^^^^^^^^^ + source.ts meta.function.expression.ts meta.block.ts meta.var.expr.ts variable.other.object.ts + ^ + source.ts meta.function.expression.ts meta.block.ts meta.var.expr.ts punctuation.accessor.ts + ^^^^^^ + source.ts meta.function.expression.ts meta.block.ts meta.var.expr.ts entity.name.function.ts + ^ + source.ts meta.function.expression.ts meta.block.ts meta.var.expr.ts meta.brace.round.ts + ^^^^^^^ + source.ts meta.function.expression.ts meta.block.ts meta.var.expr.ts variable.other.readwrite.ts + ^ + source.ts meta.function.expression.ts meta.block.ts meta.var.expr.ts meta.brace.round.ts + ^ + source.ts meta.function.expression.ts meta.block.ts meta.var.expr.ts +> if (guestContents == null) return + ^^ + source.ts meta.function.expression.ts meta.block.ts + ^^ + source.ts meta.function.expression.ts meta.block.ts keyword.control.conditional.ts + ^ + source.ts meta.function.expression.ts meta.block.ts + ^ + source.ts meta.function.expression.ts meta.block.ts meta.brace.round.ts + ^^^^^^^^^^^^^ + source.ts meta.function.expression.ts meta.block.ts variable.other.readwrite.ts + ^ + source.ts meta.function.expression.ts meta.block.ts + ^^ + source.ts meta.function.expression.ts meta.block.ts keyword.operator.comparison.ts + ^ + source.ts meta.function.expression.ts meta.block.ts + ^^^^ + source.ts meta.function.expression.ts meta.block.ts constant.language.null.ts + ^ + source.ts meta.function.expression.ts meta.block.ts meta.brace.round.ts + ^ + source.ts meta.function.expression.ts meta.block.ts + ^^^^^^ + source.ts meta.function.expression.ts meta.block.ts keyword.control.flow.ts + ^^ + source.ts meta.function.expression.ts meta.block.ts +> + ^^ + source.ts meta.function.expression.ts meta.block.ts +> if (canAccessWindow(event.sender, guestContents)) { + ^^ + source.ts meta.function.expression.ts meta.block.ts + ^^ + source.ts meta.function.expression.ts meta.block.ts keyword.control.conditional.ts + ^ + source.ts meta.function.expression.ts meta.block.ts + ^ + source.ts meta.function.expression.ts meta.block.ts meta.brace.round.ts + ^^^^^^^^^^^^^^^ + source.ts meta.function.expression.ts meta.block.ts entity.name.function.ts + ^ + source.ts meta.function.expression.ts meta.block.ts meta.brace.round.ts + ^^^^^ + source.ts meta.function.expression.ts meta.block.ts support.variable.dom.ts + ^ + source.ts meta.function.expression.ts meta.block.ts punctuation.accessor.ts + ^^^^^^ + source.ts meta.function.expression.ts meta.block.ts variable.other.property.ts + ^ + source.ts meta.function.expression.ts meta.block.ts punctuation.separator.comma.ts + ^ + source.ts meta.function.expression.ts meta.block.ts + ^^^^^^^^^^^^^ + source.ts meta.function.expression.ts meta.block.ts variable.other.readwrite.ts + ^ + source.ts meta.function.expression.ts meta.block.ts meta.brace.round.ts + ^ + source.ts meta.function.expression.ts meta.block.ts meta.brace.round.ts + ^ + source.ts meta.function.expression.ts meta.block.ts + ^ + source.ts meta.function.expression.ts meta.block.ts meta.block.ts punctuation.definition.block.ts + ^^ + source.ts meta.function.expression.ts meta.block.ts meta.block.ts +> guestContents[method](...args) + ^^^^ + source.ts meta.function.expression.ts meta.block.ts meta.block.ts + ^^^^^^^^^^^^^ + source.ts meta.function.expression.ts meta.block.ts meta.block.ts variable.other.readwrite.ts + ^ + source.ts meta.function.expression.ts meta.block.ts meta.block.ts meta.array.literal.ts meta.brace.square.ts + ^^^^^^ + source.ts meta.function.expression.ts meta.block.ts meta.block.ts meta.array.literal.ts variable.other.readwrite.ts + ^ + source.ts meta.function.expression.ts meta.block.ts meta.block.ts meta.array.literal.ts meta.brace.square.ts + ^ + source.ts meta.function.expression.ts meta.block.ts meta.block.ts meta.brace.round.ts + ^^^ + source.ts meta.function.expression.ts meta.block.ts meta.block.ts keyword.operator.spread.ts + ^^^^ + source.ts meta.function.expression.ts meta.block.ts meta.block.ts variable.other.readwrite.ts + ^ + source.ts meta.function.expression.ts meta.block.ts meta.block.ts meta.brace.round.ts + ^^ + source.ts meta.function.expression.ts meta.block.ts meta.block.ts +> } else { + ^^ + source.ts meta.function.expression.ts meta.block.ts meta.block.ts + ^ + source.ts meta.function.expression.ts meta.block.ts meta.block.ts punctuation.definition.block.ts + ^ + source.ts meta.function.expression.ts meta.block.ts + ^^^^ + source.ts meta.function.expression.ts meta.block.ts keyword.control.conditional.ts + ^ + source.ts meta.function.expression.ts meta.block.ts + ^ + source.ts meta.function.expression.ts meta.block.ts meta.block.ts punctuation.definition.block.ts + ^^ + source.ts meta.function.expression.ts meta.block.ts meta.block.ts +> console.error(`Blocked ${event.sender.getURL()} from calling ${method} on its opener.`) + ^^^^ + source.ts meta.function.expression.ts meta.block.ts meta.block.ts + ^^^^^^^ + source.ts meta.function.expression.ts meta.block.ts meta.block.ts support.class.console.ts + ^ + source.ts meta.function.expression.ts meta.block.ts meta.block.ts punctuation.accessor.ts + ^^^^^ + source.ts meta.function.expression.ts meta.block.ts meta.block.ts support.function.console.ts + ^ + source.ts meta.function.expression.ts meta.block.ts meta.block.ts meta.brace.round.ts + ^ + source.ts meta.function.expression.ts meta.block.ts meta.block.ts string.template.ts punctuation.definition.string.template.begin.ts + ^^^^^^^^ + source.ts meta.function.expression.ts meta.block.ts meta.block.ts string.template.ts + ^^ + source.ts meta.function.expression.ts meta.block.ts meta.block.ts string.template.ts meta.template.expression.ts punctuation.definition.template-expression.begin.ts + ^^^^^ + source.ts meta.function.expression.ts meta.block.ts meta.block.ts string.template.ts meta.template.expression.ts support.variable.dom.ts + ^ + source.ts meta.function.expression.ts meta.block.ts meta.block.ts string.template.ts meta.template.expression.ts punctuation.accessor.ts + ^^^^^^ + source.ts meta.function.expression.ts meta.block.ts meta.block.ts string.template.ts meta.template.expression.ts variable.other.object.property.ts + ^ + source.ts meta.function.expression.ts meta.block.ts meta.block.ts string.template.ts meta.template.expression.ts punctuation.accessor.ts + ^^^^^^ + source.ts meta.function.expression.ts meta.block.ts meta.block.ts string.template.ts meta.template.expression.ts entity.name.function.ts + ^ + source.ts meta.function.expression.ts meta.block.ts meta.block.ts string.template.ts meta.template.expression.ts meta.brace.round.ts + ^ + source.ts meta.function.expression.ts meta.block.ts meta.block.ts string.template.ts meta.template.expression.ts meta.brace.round.ts + ^ + source.ts meta.function.expression.ts meta.block.ts meta.block.ts string.template.ts meta.template.expression.ts punctuation.definition.template-expression.end.ts + ^^^^^^^^^^^^^^ + source.ts meta.function.expression.ts meta.block.ts meta.block.ts string.template.ts + ^^ + source.ts meta.function.expression.ts meta.block.ts meta.block.ts string.template.ts meta.template.expression.ts punctuation.definition.template-expression.begin.ts + ^^^^^^ + source.ts meta.function.expression.ts meta.block.ts meta.block.ts string.template.ts meta.template.expression.ts variable.other.readwrite.ts + ^ + source.ts meta.function.expression.ts meta.block.ts meta.block.ts string.template.ts meta.template.expression.ts punctuation.definition.template-expression.end.ts + ^^^^^^^^^^^^^^^ + source.ts meta.function.expression.ts meta.block.ts meta.block.ts string.template.ts + ^ + source.ts meta.function.expression.ts meta.block.ts meta.block.ts string.template.ts punctuation.definition.string.template.end.ts + ^ + source.ts meta.function.expression.ts meta.block.ts meta.block.ts meta.brace.round.ts + ^^ + source.ts meta.function.expression.ts meta.block.ts meta.block.ts +> } + ^^ + source.ts meta.function.expression.ts meta.block.ts meta.block.ts + ^ + source.ts meta.function.expression.ts meta.block.ts meta.block.ts punctuation.definition.block.ts + ^^ + source.ts meta.function.expression.ts meta.block.ts +>}) + ^ + source.ts meta.function.expression.ts meta.block.ts punctuation.definition.block.ts + ^ + source.ts meta.brace.round.ts + ^^ + source.ts +> + ^^ + source.ts +>ipcMain.on('ELECTRON_GUEST_WINDOW_MANAGER_WEB_CONTENTS_METHOD_SYNC', function (event, guestId, method, ...args) { + ^^^^^^^ + source.ts variable.other.object.ts + ^ + source.ts punctuation.accessor.ts + ^^ + source.ts entity.name.function.ts + ^ + source.ts meta.brace.round.ts + ^ + source.ts string.quoted.single.ts punctuation.definition.string.begin.ts + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + source.ts string.quoted.single.ts + ^ + source.ts string.quoted.single.ts punctuation.definition.string.end.ts + ^ + source.ts punctuation.separator.comma.ts + ^ + source.ts + ^^^^^^^^ + source.ts meta.function.expression.ts storage.type.function.ts + ^ + source.ts meta.function.expression.ts + ^ + source.ts meta.function.expression.ts meta.parameters.ts punctuation.definition.parameters.begin.ts + ^^^^^ + source.ts meta.function.expression.ts meta.parameters.ts variable.parameter.ts + ^ + source.ts meta.function.expression.ts meta.parameters.ts punctuation.separator.parameter.ts + ^ + source.ts meta.function.expression.ts meta.parameters.ts + ^^^^^^^ + source.ts meta.function.expression.ts meta.parameters.ts variable.parameter.ts + ^ + source.ts meta.function.expression.ts meta.parameters.ts punctuation.separator.parameter.ts + ^ + source.ts meta.function.expression.ts meta.parameters.ts + ^^^^^^ + source.ts meta.function.expression.ts meta.parameters.ts variable.parameter.ts + ^ + source.ts meta.function.expression.ts meta.parameters.ts punctuation.separator.parameter.ts + ^ + source.ts meta.function.expression.ts meta.parameters.ts + ^^^ + source.ts meta.function.expression.ts meta.parameters.ts keyword.operator.rest.ts + ^^^^ + source.ts meta.function.expression.ts meta.parameters.ts variable.parameter.ts + ^ + source.ts meta.function.expression.ts meta.parameters.ts punctuation.definition.parameters.end.ts + ^ + source.ts meta.function.expression.ts + ^ + source.ts meta.function.expression.ts meta.block.ts punctuation.definition.block.ts + ^^ + source.ts meta.function.expression.ts meta.block.ts +> const guestContents = webContents.fromId(guestId) + ^^ + source.ts meta.function.expression.ts meta.block.ts + ^^^^^ + source.ts meta.function.expression.ts meta.block.ts meta.var.expr.ts storage.type.ts + ^ + source.ts meta.function.expression.ts meta.block.ts meta.var.expr.ts + ^^^^^^^^^^^^^ + source.ts meta.function.expression.ts meta.block.ts meta.var.expr.ts meta.var-single-variable.expr.ts meta.definition.variable.ts variable.other.readwrite.ts + ^ + source.ts meta.function.expression.ts meta.block.ts meta.var.expr.ts meta.var-single-variable.expr.ts + ^ + source.ts meta.function.expression.ts meta.block.ts meta.var.expr.ts keyword.operator.assignment.ts + ^ + source.ts meta.function.expression.ts meta.block.ts meta.var.expr.ts + ^^^^^^^^^^^ + source.ts meta.function.expression.ts meta.block.ts meta.var.expr.ts variable.other.object.ts + ^ + source.ts meta.function.expression.ts meta.block.ts meta.var.expr.ts punctuation.accessor.ts + ^^^^^^ + source.ts meta.function.expression.ts meta.block.ts meta.var.expr.ts entity.name.function.ts + ^ + source.ts meta.function.expression.ts meta.block.ts meta.var.expr.ts meta.brace.round.ts + ^^^^^^^ + source.ts meta.function.expression.ts meta.block.ts meta.var.expr.ts variable.other.readwrite.ts + ^ + source.ts meta.function.expression.ts meta.block.ts meta.var.expr.ts meta.brace.round.ts + ^ + source.ts meta.function.expression.ts meta.block.ts meta.var.expr.ts +> if (guestContents == null) { + ^^ + source.ts meta.function.expression.ts meta.block.ts + ^^ + source.ts meta.function.expression.ts meta.block.ts keyword.control.conditional.ts + ^ + source.ts meta.function.expression.ts meta.block.ts + ^ + source.ts meta.function.expression.ts meta.block.ts meta.brace.round.ts + ^^^^^^^^^^^^^ + source.ts meta.function.expression.ts meta.block.ts variable.other.readwrite.ts + ^ + source.ts meta.function.expression.ts meta.block.ts + ^^ + source.ts meta.function.expression.ts meta.block.ts keyword.operator.comparison.ts + ^ + source.ts meta.function.expression.ts meta.block.ts + ^^^^ + source.ts meta.function.expression.ts meta.block.ts constant.language.null.ts + ^ + source.ts meta.function.expression.ts meta.block.ts meta.brace.round.ts + ^ + source.ts meta.function.expression.ts meta.block.ts + ^ + source.ts meta.function.expression.ts meta.block.ts meta.block.ts punctuation.definition.block.ts + ^^ + source.ts meta.function.expression.ts meta.block.ts meta.block.ts +> event.returnValue = null + ^^^^ + source.ts meta.function.expression.ts meta.block.ts meta.block.ts + ^^^^^ + source.ts meta.function.expression.ts meta.block.ts meta.block.ts support.variable.dom.ts + ^ + source.ts meta.function.expression.ts meta.block.ts meta.block.ts punctuation.accessor.ts + ^^^^^^^^^^^ + source.ts meta.function.expression.ts meta.block.ts meta.block.ts variable.other.property.ts + ^ + source.ts meta.function.expression.ts meta.block.ts meta.block.ts + ^ + source.ts meta.function.expression.ts meta.block.ts meta.block.ts keyword.operator.assignment.ts + ^ + source.ts meta.function.expression.ts meta.block.ts meta.block.ts + ^^^^ + source.ts meta.function.expression.ts meta.block.ts meta.block.ts constant.language.null.ts + ^^ + source.ts meta.function.expression.ts meta.block.ts meta.block.ts +> return + ^^^^ + source.ts meta.function.expression.ts meta.block.ts meta.block.ts + ^^^^^^ + source.ts meta.function.expression.ts meta.block.ts meta.block.ts keyword.control.flow.ts + ^^ + source.ts meta.function.expression.ts meta.block.ts meta.block.ts +> } + ^^ + source.ts meta.function.expression.ts meta.block.ts meta.block.ts + ^ + source.ts meta.function.expression.ts meta.block.ts meta.block.ts punctuation.definition.block.ts + ^^ + source.ts meta.function.expression.ts meta.block.ts +> + ^^ + source.ts meta.function.expression.ts meta.block.ts +> if (canAccessWindow(event.sender, guestContents)) { + ^^ + source.ts meta.function.expression.ts meta.block.ts + ^^ + source.ts meta.function.expression.ts meta.block.ts keyword.control.conditional.ts + ^ + source.ts meta.function.expression.ts meta.block.ts + ^ + source.ts meta.function.expression.ts meta.block.ts meta.brace.round.ts + ^^^^^^^^^^^^^^^ + source.ts meta.function.expression.ts meta.block.ts entity.name.function.ts + ^ + source.ts meta.function.expression.ts meta.block.ts meta.brace.round.ts + ^^^^^ + source.ts meta.function.expression.ts meta.block.ts support.variable.dom.ts + ^ + source.ts meta.function.expression.ts meta.block.ts punctuation.accessor.ts + ^^^^^^ + source.ts meta.function.expression.ts meta.block.ts variable.other.property.ts + ^ + source.ts meta.function.expression.ts meta.block.ts punctuation.separator.comma.ts + ^ + source.ts meta.function.expression.ts meta.block.ts + ^^^^^^^^^^^^^ + source.ts meta.function.expression.ts meta.block.ts variable.other.readwrite.ts + ^ + source.ts meta.function.expression.ts meta.block.ts meta.brace.round.ts + ^ + source.ts meta.function.expression.ts meta.block.ts meta.brace.round.ts + ^ + source.ts meta.function.expression.ts meta.block.ts + ^ + source.ts meta.function.expression.ts meta.block.ts meta.block.ts punctuation.definition.block.ts + ^^ + source.ts meta.function.expression.ts meta.block.ts meta.block.ts +> event.returnValue = guestContents[method](...args) + ^^^^ + source.ts meta.function.expression.ts meta.block.ts meta.block.ts + ^^^^^ + source.ts meta.function.expression.ts meta.block.ts meta.block.ts support.variable.dom.ts + ^ + source.ts meta.function.expression.ts meta.block.ts meta.block.ts punctuation.accessor.ts + ^^^^^^^^^^^ + source.ts meta.function.expression.ts meta.block.ts meta.block.ts variable.other.property.ts + ^ + source.ts meta.function.expression.ts meta.block.ts meta.block.ts + ^ + source.ts meta.function.expression.ts meta.block.ts meta.block.ts keyword.operator.assignment.ts + ^ + source.ts meta.function.expression.ts meta.block.ts meta.block.ts + ^^^^^^^^^^^^^ + source.ts meta.function.expression.ts meta.block.ts meta.block.ts variable.other.readwrite.ts + ^ + source.ts meta.function.expression.ts meta.block.ts meta.block.ts meta.array.literal.ts meta.brace.square.ts + ^^^^^^ + source.ts meta.function.expression.ts meta.block.ts meta.block.ts meta.array.literal.ts variable.other.readwrite.ts + ^ + source.ts meta.function.expression.ts meta.block.ts meta.block.ts meta.array.literal.ts meta.brace.square.ts + ^ + source.ts meta.function.expression.ts meta.block.ts meta.block.ts meta.brace.round.ts + ^^^ + source.ts meta.function.expression.ts meta.block.ts meta.block.ts keyword.operator.spread.ts + ^^^^ + source.ts meta.function.expression.ts meta.block.ts meta.block.ts variable.other.readwrite.ts + ^ + source.ts meta.function.expression.ts meta.block.ts meta.block.ts meta.brace.round.ts + ^^ + source.ts meta.function.expression.ts meta.block.ts meta.block.ts +> } else { + ^^ + source.ts meta.function.expression.ts meta.block.ts meta.block.ts + ^ + source.ts meta.function.expression.ts meta.block.ts meta.block.ts punctuation.definition.block.ts + ^ + source.ts meta.function.expression.ts meta.block.ts + ^^^^ + source.ts meta.function.expression.ts meta.block.ts keyword.control.conditional.ts + ^ + source.ts meta.function.expression.ts meta.block.ts + ^ + source.ts meta.function.expression.ts meta.block.ts meta.block.ts punctuation.definition.block.ts + ^^ + source.ts meta.function.expression.ts meta.block.ts meta.block.ts +> console.error(`Blocked ${event.sender.getURL()} from calling ${method} on its opener.`) + ^^^^ + source.ts meta.function.expression.ts meta.block.ts meta.block.ts + ^^^^^^^ + source.ts meta.function.expression.ts meta.block.ts meta.block.ts support.class.console.ts + ^ + source.ts meta.function.expression.ts meta.block.ts meta.block.ts punctuation.accessor.ts + ^^^^^ + source.ts meta.function.expression.ts meta.block.ts meta.block.ts support.function.console.ts + ^ + source.ts meta.function.expression.ts meta.block.ts meta.block.ts meta.brace.round.ts + ^ + source.ts meta.function.expression.ts meta.block.ts meta.block.ts string.template.ts punctuation.definition.string.template.begin.ts + ^^^^^^^^ + source.ts meta.function.expression.ts meta.block.ts meta.block.ts string.template.ts + ^^ + source.ts meta.function.expression.ts meta.block.ts meta.block.ts string.template.ts meta.template.expression.ts punctuation.definition.template-expression.begin.ts + ^^^^^ + source.ts meta.function.expression.ts meta.block.ts meta.block.ts string.template.ts meta.template.expression.ts support.variable.dom.ts + ^ + source.ts meta.function.expression.ts meta.block.ts meta.block.ts string.template.ts meta.template.expression.ts punctuation.accessor.ts + ^^^^^^ + source.ts meta.function.expression.ts meta.block.ts meta.block.ts string.template.ts meta.template.expression.ts variable.other.object.property.ts + ^ + source.ts meta.function.expression.ts meta.block.ts meta.block.ts string.template.ts meta.template.expression.ts punctuation.accessor.ts + ^^^^^^ + source.ts meta.function.expression.ts meta.block.ts meta.block.ts string.template.ts meta.template.expression.ts entity.name.function.ts + ^ + source.ts meta.function.expression.ts meta.block.ts meta.block.ts string.template.ts meta.template.expression.ts meta.brace.round.ts + ^ + source.ts meta.function.expression.ts meta.block.ts meta.block.ts string.template.ts meta.template.expression.ts meta.brace.round.ts + ^ + source.ts meta.function.expression.ts meta.block.ts meta.block.ts string.template.ts meta.template.expression.ts punctuation.definition.template-expression.end.ts + ^^^^^^^^^^^^^^ + source.ts meta.function.expression.ts meta.block.ts meta.block.ts string.template.ts + ^^ + source.ts meta.function.expression.ts meta.block.ts meta.block.ts string.template.ts meta.template.expression.ts punctuation.definition.template-expression.begin.ts + ^^^^^^ + source.ts meta.function.expression.ts meta.block.ts meta.block.ts string.template.ts meta.template.expression.ts variable.other.readwrite.ts + ^ + source.ts meta.function.expression.ts meta.block.ts meta.block.ts string.template.ts meta.template.expression.ts punctuation.definition.template-expression.end.ts + ^^^^^^^^^^^^^^^ + source.ts meta.function.expression.ts meta.block.ts meta.block.ts string.template.ts + ^ + source.ts meta.function.expression.ts meta.block.ts meta.block.ts string.template.ts punctuation.definition.string.template.end.ts + ^ + source.ts meta.function.expression.ts meta.block.ts meta.block.ts meta.brace.round.ts + ^^ + source.ts meta.function.expression.ts meta.block.ts meta.block.ts +> event.returnValue = null + ^^^^ + source.ts meta.function.expression.ts meta.block.ts meta.block.ts + ^^^^^ + source.ts meta.function.expression.ts meta.block.ts meta.block.ts support.variable.dom.ts + ^ + source.ts meta.function.expression.ts meta.block.ts meta.block.ts punctuation.accessor.ts + ^^^^^^^^^^^ + source.ts meta.function.expression.ts meta.block.ts meta.block.ts variable.other.property.ts + ^ + source.ts meta.function.expression.ts meta.block.ts meta.block.ts + ^ + source.ts meta.function.expression.ts meta.block.ts meta.block.ts keyword.operator.assignment.ts + ^ + source.ts meta.function.expression.ts meta.block.ts meta.block.ts + ^^^^ + source.ts meta.function.expression.ts meta.block.ts meta.block.ts constant.language.null.ts + ^^ + source.ts meta.function.expression.ts meta.block.ts meta.block.ts +> } + ^^ + source.ts meta.function.expression.ts meta.block.ts meta.block.ts + ^ + source.ts meta.function.expression.ts meta.block.ts meta.block.ts punctuation.definition.block.ts + ^^ + source.ts meta.function.expression.ts meta.block.ts +>}) + ^ + source.ts meta.function.expression.ts meta.block.ts punctuation.definition.block.ts + ^ + source.ts meta.brace.round.ts \ No newline at end of file diff --git a/tests/cases/Issue402.ts b/tests/cases/Issue402.ts new file mode 100644 index 00000000..23794fa3 --- /dev/null +++ b/tests/cases/Issue402.ts @@ -0,0 +1,25 @@ +ipcMain.on('ELECTRON_GUEST_WINDOW_MANAGER_WEB_CONTENTS_METHOD', function (event, guestId, method, ...args) { + const guestContents = webContents.fromId(guestId) + if (guestContents == null) return + + if (canAccessWindow(event.sender, guestContents)) { + guestContents[method](...args) + } else { + console.error(`Blocked ${event.sender.getURL()} from calling ${method} on its opener.`) + } +}) + +ipcMain.on('ELECTRON_GUEST_WINDOW_MANAGER_WEB_CONTENTS_METHOD_SYNC', function (event, guestId, method, ...args) { + const guestContents = webContents.fromId(guestId) + if (guestContents == null) { + event.returnValue = null + return + } + + if (canAccessWindow(event.sender, guestContents)) { + event.returnValue = guestContents[method](...args) + } else { + console.error(`Blocked ${event.sender.getURL()} from calling ${method} on its opener.`) + event.returnValue = null + } +}) \ No newline at end of file