0

I'm working in a Chrome extension. At some point, in a script called CLAWS_Sem_Imagens_Script.js, I send a message from an Iframe inside the page to my background-page with the following line:

chrome.runtime.sendMessage({type:"execution order",sendToContentScript:true, data:"show"}); 

It works most of the times. However, sometimes, javascript throws the error Cannot read property "name" of undefined, at the line 316 of @extensions::messaging:

if (port.name != kNativeMessageChannel)...

The full call stack is:

sendMessageImpl @ extensions::messaging:316
(anonymous function) @ extensions::runtime:115
target.(anonymous function) @ extensions::SafeBuiltins:19
(anonymous function) @ extensions::binding:57
target.(anonymous function) @ extensions::SafeBuiltins:19
(anonymous function) @ extensions::binding:385
enviaPalavraAoBackgroundPageImagem @ CLAWS_Sem_Imagens_Script.js:66

Do someone has any guess? Please ask me for any additional info you need.

EDIT: My manifest:

{
  "manifest_version": 2,

  "name": "name",
  "description": "description",
  "version": "1.0",

  "permissions": [
    "tabs",
    "activeTab",
    "https://google.com.br/",
    "http://localhost/*",
    "https://localhost/*"
  ],


 "background": {"scripts":["background.js"]},

  "content_scripts": [
    {
      "js": ["CLAWS_Content_Script.js", "jquery.js", "Caixas_De_Texto_Dos_Botoes.js"],
      "css": ["CLAWS_Content_Script_CSS.css"],
      "matches": ["<all_urls>"]

    }
  ],

  "web_accessible_resources": [
        "iframe.html",
        "icon.png",
        "Caixas_De_Texto_Dos_Botoes.js",
        "search.png"
  ]


}
10
  • Are you using an event page ("persistent": false)? Where is that error displayed (webpage console or background page console)? And just in case add your manifest.json to the question. Commented Nov 16, 2015 at 21:46
  • @wOxxom no, just a background page! The error is displayed at the consolse we see when we open the developer tools - I make no idea of how we call it. And the manifest is added : ) Commented Nov 16, 2015 at 21:52
  • First option! I didn't know this second one, for saying the truth! Commented Nov 16, 2015 at 21:55
  • @wOxxOm think I found out, and it was really a stupidness of mine if it is true. When I tried to send the message, the extensions was disabled (though the page wasn't updated, so I didn't realize it). I'll try to confirm that! Commented Nov 16, 2015 at 21:58
  • 1
    @That1guyoverthr I don't know if it's your case, but if you are in one page and you disable the extension (going at chrome://extensions and unmarking the box aside it), but remain on that page, the extension apparently continues to work, but it's background page gets disabled...hope it helps! Commented Nov 30, 2015 at 23:19

2 Answers 2

2

This can also occur if you reload the extension but not the page with injected script. Reloading the page solves the problem.

Sign up to request clarification or add additional context in comments.

Comments

0

Just to clarify, the error was occurring because the extension was disabled (chrome://extensions -> unmark the check box), and then the background page was disabled, even with the extension aparently working. Regards!

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.