示例#1
0
    def testGetAPINodeAvailability(self):
        def assertEquals(node, actual):
            node_availabilities = {
                'tabs.Tab': None,
                'tabs.fakeTabsProperty1': None,
                'tabs.get': None,
                'tabs.onUpdated': None,
                'tabs.InjectDetails': 25,
                'tabs.fakeTabsProperty2': 15,
                'tabs.getCurrent': 19,
                'tabs.onActivated': 30
            }
            self.assertEquals(node_availabilities[node], actual)

        model_dict = CreateJSCView(
            self._api_models.GetContentScriptAPIs().Get(),
            self._api_models.GetModel('tabs').Get(),
            self._avail_finder, self._json_cache, _FakeTemplateCache(),
            _FakeFeaturesBundle(), None, 'extensions', [], Request.ForTest(''))

        # Test nodes that have the same availability as their parent.

        # Test type.
        assertEquals('tabs.Tab', model_dict['types'][0]['availability'])
        # Test property.
        assertEquals('tabs.fakeTabsProperty1',
                     model_dict['properties'][1]['availability'])
        # Test function.
        assertEquals('tabs.get', model_dict['functions'][1]['availability'])
        # Test event.
        assertEquals('tabs.onUpdated', model_dict['events'][1]['availability'])

        # Test nodes with varying availabilities.

        # Test type.
        assertEquals('tabs.InjectDetails',
                     model_dict['types'][1]['availability']['version'])
        # Test property.
        assertEquals('tabs.fakeTabsProperty2',
                     model_dict['properties'][3]['availability']['version'])
        # Test function.
        assertEquals('tabs.getCurrent',
                     model_dict['functions'][0]['availability']['version'])
        # Test event.
        assertEquals('tabs.onActivated',
                     model_dict['events'][0]['availability']['version'])

        # Test a node that became deprecated.
        self.assertEquals(
            {
                'scheduled':
                None,
                'version':
                26,
                'partial':
                'motemplate chrome/common/extensions/docs/templates/' +
                'private/intro_tables/deprecated_message.html'
            }, model_dict['types'][2]['availability'])
示例#2
0
 def DISABLED_testToDict(self):
     fake_avail_finder = _FakeAvailabilityFinder(self._fake_availability)
     expected_json = self._LoadJSON('expected_tester.json')
     dict_ = CreateJSCView(self._api_models.GetContentScriptAPIs().Get(),
                           self._api_models.GetModel('tester').Get(),
                           fake_avail_finder, self._json_cache,
                           _FakeTemplateCache(), self._features_bundle,
                           None, 'extensions', [], Request.ForTest(''))
     self.assertEquals(expected_json, dict_)
示例#3
0
 def resolve():
     jsc_view = jsc_view_future.Get()
     if jsc_view is None:
         jsc_view = CreateJSCView(
             content_script_apis_future.Get(), model_future.Get(),
             self._platform_bundle.GetAvailabilityFinder(platform),
             self._json_cache, self._template_cache,
             self._platform_bundle.GetFeaturesBundle(platform),
             self._LoadEventByName(platform), platform,
             samples_future.Get(), self._request)
         self._view_cache.Set(object_store_key, jsc_view)
     return jsc_view
示例#4
0
 def testCreateId(self):
     fake_avail_finder = _FakeAvailabilityFinder(self._fake_availability)
     dict_ = CreateJSCView(self._api_models.GetContentScriptAPIs().Get(),
                           self._api_models.GetModel('tester').Get(),
                           fake_avail_finder, self._json_cache,
                           _FakeTemplateCache(), self._features_bundle,
                           None, 'extensions', [], Request.ForTest(''))
     self.assertEquals('type-TypeA', dict_['types'][0]['id'])
     self.assertEquals('property-TypeA-b',
                       dict_['types'][0]['properties'][0]['id'])
     self.assertEquals('method-get', dict_['functions'][0]['id'])
     self.assertEquals('event-EventA', dict_['events'][0]['id'])
示例#5
0
 def testGetAPIAvailability(self):
     api_availabilities = {
         'bluetooth': 31,
         'contextMenus': 'master',
         'jsonStableAPI': 20,
         'idle': 5,
         'input.ime': 18,
         'tabs': 18
     }
     for api_name, availability in api_availabilities.iteritems():
         model_dict = CreateJSCView(
             self._api_models.GetContentScriptAPIs().Get(),
             self._api_models.GetModel(api_name).Get(),
             self._avail_finder, self._json_cache, _FakeTemplateCache(),
             _FakeFeaturesBundle(), None, 'extensions', [],
             Request.ForTest(''))
         self.assertEquals(
             availability,
             model_dict['introList'][1]['content'][0]['version'])
示例#6
0
    def testAddRules(self):
        fake_avail_finder = _FakeAvailabilityFinder(self._fake_availability)
        dict_ = CreateJSCView(
            self._api_models.GetContentScriptAPIs().Get(),
            self._api_models.GetModel('add_rules_tester').Get(),
            fake_avail_finder, self._json_cache,
            _FakeTemplateCache(), self._features_bundle,
            self._FakeLoadAddRulesSchema(), 'extensions', [],
            Request.ForTest(''))

        # Check that the first event has the addRulesFunction defined.
        self.assertEquals('add_rules_tester', dict_['name'])
        self.assertEquals('rules', dict_['events'][0]['name'])
        self.assertEquals(
            'notable_name_to_check_for',
            dict_['events'][0]['byName']['addRules']['parameters'][0]['name'])

        # Check that the second event has addListener defined.
        self.assertEquals('noRules', dict_['events'][1]['name'])
        self.assertEquals('add_rules_tester', dict_['name'])
        self.assertEquals('noRules', dict_['events'][1]['name'])
        self.assertEquals(
            'callback', dict_['events'][0]['byName']['addListener']
            ['parameters'][0]['name'])