Validate debuggee.targetId before use in chrome.debugger

And refactored the tests to make sure that the debugger is detached upon
returning from RunAttachFunction. Previously, if the debugger
unexpectedly succeeded in attaching, the method would return (because
empty error != some error), causing the attached debugger to not be
detached.

R=rdevlin.cronin@chromium.org
BUG=456841
TEST=browser_tests DebuggerApiTest.DebuggerNotAllowedOnOtherExtensionPages

Review URL: https://codereview.chromium.org/910053002

Cr-Commit-Position: refs/heads/master@{#315675}
2 files changed