diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /addon-sdk/source/test/test-page-mod-debug.js | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'addon-sdk/source/test/test-page-mod-debug.js')
-rw-r--r-- | addon-sdk/source/test/test-page-mod-debug.js | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/addon-sdk/source/test/test-page-mod-debug.js b/addon-sdk/source/test/test-page-mod-debug.js new file mode 100644 index 000000000..86f491149 --- /dev/null +++ b/addon-sdk/source/test/test-page-mod-debug.js @@ -0,0 +1,66 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +"use strict"; + +const { Cc, Ci, Cu } = require("chrome"); +const { PageMod } = require("sdk/page-mod"); +const { testPageMod, handleReadyState, openNewTab, + contentScriptWhenServer, createLoader } = require("./page-mod/helpers"); +const { cleanUI, after } = require("sdk/test/utils"); +const { open, getFrames, getMostRecentBrowserWindow, getInnerId } = require("sdk/window/utils"); + +const { devtools } = Cu.import("resource://devtools/shared/Loader.jsm", {}); +const { require: devtoolsRequire } = devtools; +const contentGlobals = devtoolsRequire("devtools/server/content-globals"); + +// The following adds Debugger constructor to the global namespace. +const { addDebuggerToGlobal } = require('resource://gre/modules/jsdebugger.jsm'); +addDebuggerToGlobal(this); + +exports.testDebugMetadata = function(assert, done) { + let dbg = new Debugger; + let globalDebuggees = []; + dbg.onNewGlobalObject = function(global) { + globalDebuggees.push(global); + } + + let mods = testPageMod(assert, done, "about:", [{ + include: "about:", + contentScriptWhen: "start", + contentScript: "null;", + }], function(win, done) { + assert.ok(globalDebuggees.some(function(global) { + try { + let metadata = Cu.getSandboxMetadata(global.unsafeDereference()); + return metadata && metadata.addonID && metadata.SDKContentScript && + metadata['inner-window-id'] == getInnerId(win); + } catch(e) { + // Some of the globals might not be Sandbox instances and thus + // will cause getSandboxMetadata to fail. + return false; + } + }), "one of the globals is a content script"); + done(); + } + ); +}; + +exports.testDevToolsExtensionsGetContentGlobals = function(assert, done) { + let mods = testPageMod(assert, done, "about:", [{ + include: "about:", + contentScriptWhen: "start", + contentScript: "null;", + }], function(win, done) { + assert.equal(contentGlobals.getContentGlobals({ 'inner-window-id': getInnerId(win) }).length, 1); + done(); + } + ); +}; + +after(exports, function*(name, assert) { + assert.pass("cleaning ui."); + yield cleanUI(); +}); + +require('sdk/test').run(exports); |