Scripts may close only the windows that were opened by them

Hello everyone , I have question about the window.close() ,I have a button when I cliked to close the window I get this message “scripts may close only the windows that were opened by them” , even I try’’, ‘_self’, ‘’); window.close(); nothing seems working . can someone help me to solve this .

let cancelButton = document.querySelector("#cancel");
cancelButton.addEventListener("click", () => {


Grateful for help! :star_struck:

It is hard to answer this question without being able to see all of your code. I’ll just point out that Window.close() and window.close() are not the same thing. Is Window pointing to a WindowProxy object returned by

no I don’t think so but this is window open() method !!

“use strict”;
var { Preferences } = ChromeUtils.import(“resource://gre/modules/Preferences.jsm”);
var { Services } = ChromeUtils.import(“resource://gre/modules/Services.jsm”);

var { ExtensionCommon } = ChromeUtils.import(“resource://gre/modules/ExtensionCommon.jsm”);

const OBMSettingsBranch = “obmSetting.”;
this.obm_settings = class extends ExtensionCommon.ExtensionAPI {
onStartup() {

getAPI(context) {
var { obmSettingsManager } = ChromeUtils.import(“resource://obm-connector/obmSettings/modules/settingsManager.jsm”);


return {
  obm: {
    settings: {
      showPrefsPane: function () {
        Services.ww.openWindow(null, "resource://obm-connector/settings.html", '_blank', 'chrome,dialog,centerscreen', {})

Well, that snippet of code didn’t really help me. For security reasons, a script can only close windows that they opened. So just calling window.close() is not going to work. Your script must first open a new window (and save a reference to that window) and then it can use that reference to close the window.

If you are getting the error message “scripts may close only the windows that were opened by them” then you are violating that security principle somehow.