(function(window) { 'use strict'; var template = ` `; var proto = Object.create(HTMLElement.prototype); proto.createdCallback = function() { this.shadow = this.createShadowRoot(); this.shadow.innerHTML = template; this.modalDialog = this.shadow.querySelector('.modal-dialog'); this.cancelButton = this.shadow.querySelector('.cancel'); this.continueButton = this.shadow.querySelector('.continue'); this.cancelButton.addEventListener( 'click', this.handleCancel.bind(this)); this.continueButton.addEventListener( 'click', this.handleContinue.bind(this)); // If dev mode perf is enabled emit 'enabled' event else // show the confirm modal dialog navigator.getFeature('dom.apps.developer_mode').then(enabled => { if (enabled) { // Emit Enabled Event this.dispatchEvent(new CustomEvent('enabled')); } else { this.modalDialog.classList.remove('hidden'); } }); }; proto.handleCancel = function(e) { window.close(); }; proto.handleContinue = function(e) { // Invoke Settings activity to enable developer mode // XXX: Bug 1163889 var activity = new window.MozActivity({ name: 'configure', data: { target: 'device', section: 'full-developer-mode' } }); activity.onerror = function() { console.log('Settings configure activity error:', activity.error.name); }; }; try { document.registerElement('fxos-dev-mode-dialog', { prototype: proto }); } catch (e) { if (e.name !== 'NotSupportedError') { throw e; } } })(window);