diff --git a/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/ApiPaneTests/API_Unique_name_spec.js b/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/ApiPaneTests/API_Unique_name_spec.js index 48655115a4..13f575601e 100644 --- a/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/ApiPaneTests/API_Unique_name_spec.js +++ b/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/ApiPaneTests/API_Unique_name_spec.js @@ -14,4 +14,11 @@ describe("Name uniqueness test", function() { it("Validate download apiname check", () => { cy.CreationOfUniqueAPIcheck("download"); }); + + it("Validate window object property apiname check", () => { + cy.CreationOfUniqueAPIcheck("localStorage"); + }); + it("Validate window object method apiname check", () => { + cy.CreationOfUniqueAPIcheck("resizeTo"); + }); }); diff --git a/app/client/src/constants/WidgetValidation.ts b/app/client/src/constants/WidgetValidation.ts index 09258045e2..b0efb86f61 100644 --- a/app/client/src/constants/WidgetValidation.ts +++ b/app/client/src/constants/WidgetValidation.ts @@ -87,3 +87,64 @@ export const DATA_TREE_KEYWORDS = { pageList: "pageList", [EXECUTION_PARAM_KEY]: EXECUTION_PARAM_KEY, }; + +export const WINDOW_OBJECT_PROPERTIES = { + closed: "closed", + console: "console", + defaultStatus: "defaultStatus", + document: "document", + frameElement: "frameElement", + frames: "frames", + history: "history", + innerHeight: "innerHeight", + innerWidth: "innerWidth", + length: "length", + localStorage: "localStorage", + location: "location", + name: "name", + navigator: "navigator", + opener: "opener", + outerHeight: "outerHeight", + outerWidth: "outerWidth", + pageXOffset: "pageXOffset", + pageYOffset: "pageYOffset", + parent: "parent", + screen: "screen", + screenLeft: "screenLeft", + screenTop: "screenTop", + screenY: "screenY", + scrollX: "scrollX", + scrollY: "scrollY", + self: "self", + status: "status", + top: "top", +}; + +export const WINDOW_OBJECT_METHODS = { + alert: "alert", + atob: "atob", + blur: "blur", + btoa: "btoa", + clearInterval: "clearInterval", + clearTimeout: "clearTimeout", + close: "close", + confirm: "confirm", + focus: "focus", + getComputedStyle: "getComputedStyle", + getSelection: "getSelection", + matchMedia: "matchMedia", + moveBy: "moveBy", + moveTo: "moveTo", + open: "open", + print: "print", + prompt: "prompt", + requestAnimationFrame: "requestAnimationFrame", + resizeBy: "resizeBy", + resizeTo: "resizeTo", + scroll: "scroll", + scrollBy: "scrollBy", + scrollTo: "scrollBy", + setInterval: "setInterval", + setTimeout: "setTimeout", + stop: "stop", +}; diff --git a/app/client/src/utils/helpers.tsx b/app/client/src/utils/helpers.tsx index b398697ab4..465ca20ee1 100644 --- a/app/client/src/utils/helpers.tsx +++ b/app/client/src/utils/helpers.tsx @@ -7,6 +7,8 @@ import successAnimation from "assets/lottie/success-animation.json"; import { DATA_TREE_KEYWORDS, JAVASCRIPT_KEYWORDS, + WINDOW_OBJECT_METHODS, + WINDOW_OBJECT_PROPERTIES, } from "constants/WidgetValidation"; import { GLOBAL_FUNCTIONS } from "./autocomplete/EntityDefinitions"; import { set } from "lodash"; @@ -280,6 +282,8 @@ export const isNameValid = ( name in JAVASCRIPT_KEYWORDS || name in DATA_TREE_KEYWORDS || name in GLOBAL_FUNCTIONS || + name in WINDOW_OBJECT_PROPERTIES || + name in WINDOW_OBJECT_METHODS || name in invalidNames ); };