The background.js
script is executed inside the background page context. Here, since you only declare a background script, your background page is generated, and doesn't have any content.
You can see the generated background page by going to chrome://extensions/ and clicking on the Inspect views: _generated_background_page.html
link next to your extension. It will look like this:
<!DOCTYPE html>
<html>
<head></head>
<body>
<script src="background.js"></script>
</body>
</html>
As you can see, there are no <div>
element, and therefore document.getElementsByTagName("div").length
will return 0.
If you want to get the content of the web page, you'll have to use a content script.