Permalink
Browse files

Second pass

  • Loading branch information...
1 parent ac8e016 commit b38db0cac748515c3b93b1dfd766b156f3d4c1be @mattbasta committed Aug 1, 2012
Showing with 159 additions and 44,998 deletions.
  1. +1 −2 .gitignore
  2. +0 −102 appvalidator/app_versions.json
  3. +0 −240 appvalidator/chromemanifest.py
  4. +0 −52 appvalidator/compat.py
  5. +1 −10 appvalidator/constants.py
  6. +2 −32 appvalidator/decorator.py
  7. +7 −75 appvalidator/errorbundler.py
  8. +2 −11 appvalidator/loader.py
  9. +1 −55 appvalidator/main.py
  10. +0 −230 appvalidator/opensearch.py
  11. +0 −146 appvalidator/rdf.py
  12. +4 −161 appvalidator/submain.py
  13. +0 −112 appvalidator/testcases/chromemanifest.py
  14. +0 −88 appvalidator/testcases/conduit.py
  15. +9 −42 appvalidator/testcases/content.py
  16. +0 −250 appvalidator/testcases/installrdf.py
  17. +1 −40 appvalidator/testcases/javascript/actions.py
  18. +1 −725 appvalidator/testcases/javascript/call_definitions.py
  19. +2 −179 appvalidator/testcases/javascript/entity_values.py
  20. +16 −130 appvalidator/testcases/javascript/instanceactions.py
  21. +4 −72 appvalidator/testcases/javascript/instanceproperties.py
  22. +3 −40 appvalidator/testcases/javascript/jstypes.py
  23. +1 −338 appvalidator/testcases/javascript/predefinedentities.py
  24. +8 −8 appvalidator/testcases/javascript/spidermonkey.py
  25. +6 −45 appvalidator/testcases/javascript/traverser.py
  26. +0 −265 appvalidator/testcases/jetpack.py
  27. +0 −32,566 appvalidator/testcases/jetpack_data.txt
  28. 0 appvalidator/testcases/l10n/__init__.py
  29. +0 −88 appvalidator/testcases/l10n/dtd.py
  30. +0 −75 appvalidator/testcases/l10n/properties.py
  31. +0 −515 appvalidator/testcases/l10ncompleteness.py
  32. +0 −93 appvalidator/testcases/langpack.py
  33. BIN appvalidator/testcases/langpacks/fennec.xpi
  34. BIN appvalidator/testcases/langpacks/firefox.xpi
  35. BIN appvalidator/testcases/langpacks/mozilla.xpi
  36. BIN appvalidator/testcases/langpacks/seamonkey.xpi
  37. BIN appvalidator/testcases/langpacks/sunbird.xpi
  38. BIN appvalidator/testcases/langpacks/thunderbird.xpi
  39. +1 −39 appvalidator/testcases/markup/csstester.py
  40. +6 −247 appvalidator/testcases/markup/markuptester.py
  41. +4 −121 appvalidator/testcases/packagelayout.py
  42. +0 −860 appvalidator/testcases/regex.py
  43. +6 −19 appvalidator/testcases/scripting.py
  44. +0 −208 appvalidator/testcases/targetapplication.py
  45. +0 −31 appvalidator/testcases/themes.py
  46. +0 −1 appvalidator/textfilter.py
  47. +0 −90 appvalidator/typedetection.py
  48. +0 −84 appvalidator/validate.py
  49. +0 −84 appvalidator/version.py
  50. +2 −2 appvalidator/webapp.py
  51. 0 tests/compat/__init__.py
  52. +0 −96 tests/compat/helper.py
  53. +0 −66 tests/compat/test_gecko10.py
  54. +0 −27 tests/compat/test_gecko11.py
  55. +0 −27 tests/compat/test_gecko12.py
  56. +0 −55 tests/compat/test_gecko13.py
  57. +0 −81 tests/compat/test_gecko14.py
  58. +0 −20 tests/compat/test_gecko5.py
  59. +0 −84 tests/compat/test_gecko6.py
  60. +0 −40 tests/compat/test_gecko7.py
  61. +0 −29 tests/compat/test_gecko8.py
  62. +0 −155 tests/compat/test_gecko9.py
  63. +0 −22 tests/compat/test_tb10.py
  64. +0 −22 tests/compat/test_tb11.py
  65. +0 −22 tests/compat/test_tb12.py
  66. +0 −38 tests/compat/test_tb13.py
  67. +0 −35 tests/compat/test_tb14.py
  68. +0 −21 tests/compat/test_tb6.py
  69. +0 −50 tests/compat/test_tb7.py
  70. +0 −15 tests/compat/test_tb8.py
  71. +0 −17 tests/compat/test_tb9.py
  72. +4 −40 tests/helper.py
  73. +13 −17 tests/js_helper.py
  74. +0 −216 tests/resources/bootstrap.js
  75. +0 −5 tests/resources/chromemanifest/chrome.manifest
  76. BIN tests/resources/conduit/basta_bar.xpi
  77. BIN tests/resources/conduit/conduit_chrome.xpi
  78. BIN tests/resources/conduit/conduit_params.xpi
  79. BIN tests/resources/conduit/conduit_structure.xpi
  80. BIN tests/resources/conduit/conduit_updateurl.xpi
  81. BIN tests/resources/conduit/pass.xpi
  82. +0 −33 tests/resources/installrdf/doctype.rdf
  83. +0 −30 tests/resources/installrdf/may_exist_extra.rdf
  84. +0 −29 tests/resources/installrdf/may_exist_missing.rdf
  85. +0 −33 tests/resources/installrdf/may_exist_once_extra.rdf
  86. +0 −32 tests/resources/installrdf/may_exist_once_missing.rdf
  87. +0 −34 tests/resources/installrdf/may_exist_once_theme.rdf
  88. +0 −35 tests/resources/installrdf/may_exist_once_theme_fail.rdf
  89. +0 −33 tests/resources/installrdf/must_exist_once_extra.rdf
  90. +0 −31 tests/resources/installrdf/must_exist_once_missing.rdf
  91. +0 −38 tests/resources/installrdf/mustmay_exist_extra.rdf
  92. +0 −32 tests/resources/installrdf/obsolete.rdf
  93. +0 −34 tests/resources/installrdf/pass.rdf
  94. +0 −32 tests/resources/installrdf/shouldnt_exist.rdf
  95. +0 −34 tests/resources/installrdf/unpack.rdf
  96. BIN tests/resources/jetpack/jetpack-1.8-outdated.xpi
  97. BIN tests/resources/jetpack/jetpack-1.8-pretending-1.8.1.xpi
  98. +0 −21 tests/resources/l10n/dtd/extra_breaks.dtd
  99. +0 −10 tests/resources/l10n/dtd/malformed.dtd
  100. +0 −9 tests/resources/l10n/dtd/valid.dtd
  101. BIN tests/resources/l10n/l10n_incomplete.xpi
  102. BIN tests/resources/l10n/l10n_missingfiles.xpi
  103. BIN tests/resources/l10n/l10n_multpreds.xpi
  104. BIN tests/resources/l10n/l10n_unmodified.xpi
  105. BIN tests/resources/l10n/langpack/extra_files.jar
  106. BIN tests/resources/l10n/langpack/extra_files_ref.jar
  107. BIN tests/resources/l10n/langpack/missing_entities.jar
  108. BIN tests/resources/l10n/langpack/missing_file.jar
  109. BIN tests/resources/l10n/langpack/missing_file_entities.jar
  110. BIN tests/resources/l10n/langpack/pass.jar
  111. BIN tests/resources/l10n/langpack/reference.jar
  112. BIN tests/resources/l10n/localizable.xpi
  113. BIN tests/resources/l10n/pass.xpi
  114. +0 −5 tests/resources/l10n/properties/extra_breaks.properties
  115. +0 −12 tests/resources/l10n/properties/valid.properties
  116. BIN tests/resources/l10n/unlocalizable.xpi
  117. BIN tests/resources/langpack/fail.xpi
  118. BIN tests/resources/langpack/fail_uri_obj.xpi
  119. BIN tests/resources/langpack/fail_uri_pred.xpi
  120. BIN tests/resources/langpack/nested.xpi
  121. BIN tests/resources/langpack/pass.xpi
  122. +0 −18 tests/resources/rdf/fail.rdf
  123. +0 −22 tests/resources/rdf/pass.rdf
  124. +0 −9 tests/resources/searchprovider/bad_xmlns.xml
  125. +0 −8 tests/resources/searchprovider/no_xmlns.xml
  126. +0 −9 tests/resources/searchprovider/pass.xml
  127. +0 −7 tests/resources/searchprovider/rel_self_url.xml
  128. +0 −9 tests/resources/searchprovider/sp_bad_param_atts.xml
  129. +0 −9 tests/resources/searchprovider/sp_bad_url_atts.xml
  130. +0 −9 tests/resources/searchprovider/sp_bad_url_mime.xml
  131. +0 −10 tests/resources/searchprovider/sp_dup_shortname.xml
  132. +0 −7 tests/resources/searchprovider/sp_inline_template.xml
  133. +0 −9 tests/resources/searchprovider/sp_long_shortname.xml
  134. +0 −8 tests/resources/searchprovider/sp_no_description.xml
  135. +0 −8 tests/resources/searchprovider/sp_no_shortname.xml
  136. +0 −6 tests/resources/searchprovider/sp_no_url.xml
  137. +0 −7 tests/resources/searchprovider/sp_no_url_template.xml
  138. +0 −9 tests/resources/searchprovider/sp_notos.xml
  139. +0 −9 tests/resources/searchprovider/sp_param_template.xml
  140. +0 −10 tests/resources/searchprovider/sp_updateurl.xml
  141. BIN tests/resources/targetapplication/bad_max.xpi
  142. BIN tests/resources/targetapplication/bad_min.xpi
  143. BIN tests/resources/targetapplication/bad_order.xpi
  144. BIN tests/resources/targetapplication/dup_targapp.xpi
  145. BIN tests/resources/targetapplication/ff4.xpi
  146. BIN tests/resources/targetapplication/missing_max.xpi
  147. BIN tests/resources/targetapplication/missing_min.xpi
  148. BIN tests/resources/targetapplication/pass.xpi
  149. +0 −1 tests/resources/test_app_versions.json
  150. BIN tests/resources/themes/fail.jar
  151. BIN tests/resources/themes/pass.jar
  152. +0 −165 tests/test_chromemanifest.py
  153. +0 −111 tests/test_chromemanifest_testcases.py
  154. +0 −92 tests/test_conduit.py
  155. +4 −23 tests/test_content.py
  156. +0 −112 tests/test_content_overlays.py
  157. +2 −89 tests/test_content_scripts.py
  158. +1 −1 tests/test_contextgenerator.py
  159. +6 −6 tests/test_controlchars.py
  160. +1 −28 tests/test_decorator.py
  161. +4 −100 tests/test_errorbundler.py
  162. +0 −292 tests/test_installrdf.py
  163. +0 −385 tests/test_jetpack.py
  164. +0 −48 tests/test_js_bootstrapped.py
  165. +0 −42 tests/test_js_content_scripts.py
  166. +1 −1 tests/test_js_e4x.py
  167. +0 −45 tests/test_js_instanceactions.py
  168. +0 −26 tests/test_js_jsm.py
  169. +1 −1 tests/test_js_jstypes.py
  170. +0 −108 tests/test_js_pollution.py
  171. +0 −60 tests/test_js_prefs.py
  172. +4 −4 tests/test_js_spidermonkey.py
  173. +1 −1 tests/test_js_wrappedjsobject.py
  174. +0 −306 tests/test_js_xpcom.py
  175. +0 −92 tests/test_l10n.py
  176. +0 −57 tests/test_l10n_dtd.py
  177. +0 −137 tests/test_l10n_helpers.py
  178. +0 −127 tests/test_l10n_langpack.py
  179. +0 −47 tests/test_l10n_properties.py
  180. +0 −106 tests/test_langpack.py
  181. +0 −51 tests/test_libraryblacklist.py
  182. +3 −15 tests/test_markup_csstester.py
  183. +4 −108 tests/test_markup_markuptester.py
  184. +0 −138 tests/test_opensearch.py
  185. +2 −213 tests/test_packagelayout.py
  186. +0 −69 tests/test_packagelayout_unpack.py
  187. +0 −80 tests/test_rdf.py
  188. +0 −218 tests/test_regex.py
  189. +3 −124 tests/test_submain.py
  190. +0 −91 tests/test_submain_install_rdf.py
  191. +3 −3 tests/test_submain_package.py
  192. +0 −142 tests/test_submain_versions.py
  193. +0 −269 tests/test_targetapplication.py
  194. +1 −1 tests/test_textfilter.py
  195. +0 −35 tests/test_themes.py
  196. +0 −108 tests/test_typedetection.py
  197. +1 −1 tests/test_unicodehelper.py
  198. +1 −129 tests/test_validate.py
  199. +0 −106 tests/test_version.py
  200. +10 −10 tests/test_webapp.py
  201. +1 −1 tests/test_xpimanager.py
View
@@ -5,7 +5,6 @@
.coverage
.figleaf
*.swp
-/validator/constants_local.py
+/appvalidator/constants_local.py
/src
/extras/jslibs
-/extras/language_controls
@@ -1,102 +0,0 @@
-{
- "1":{"name":"Firefox",
- "guid":"{ec8030f7-c20a-464f-9b0e-13a3a9e97384}",
- "versions":
- ["0.3", "0.6", "0.7", "0.7+", "0.8", "0.8+", "0.9.x", "0.9", "0.9.0+",
- "0.9.1+", "0.9.2+", "0.9.3", "0.9.3+", "0.9+", "0.10", "0.10.1",
- "0.10+", "1.0", "1.0.1", "1.0.2", "1.0.3", "1.0.4", "1.0.5", "1.0.6",
- "1.0.7", "1.0.8", "1.0+", "1.4", "1.4.0", "1.4.1", "1.5b1", "1.5b2",
- "1.5", "1.5.0.4", "1.5.0.*", "2.0a1", "2.0a2", "2.0a3", "2.0b1",
- "2.0b2", "2.0", "2.0.0.4", "2.0.0.8", "2.0.0.*", "3.0a1", "3.0a2",
- "3.0a3", "3.0a4", "3.0a5", "3.0a6", "3.0a7", "3.0a8pre", "3.0a8",
- "3.0a9", "3.0b1", "3.0b2pre", "3.0b2", "3.0b3pre", "3.0b3",
- "3.0b4pre", "3.0b4", "3.0b5pre", "3.0b5", "3.0pre", "3.0", "3.0.9",
- "3.0.11", "3.0.12", "3.0.*", "3.1a1pre", "3.1a1", "3.1a2pre", "3.1a2",
- "3.1b1pre", "3.1b1", "3.1b2pre", "3.1b2", "3.1b3pre", "3.1b3",
- "3.5b4pre", "3.5b4", "3.5b5pre", "3.5", "3.5.*", "3.6a1pre", "3.6a1",
- "3.6a2pre", "3.6b1pre", "3.6b2", "3.6", "3.6.4", "3.6.*", "3.7a1pre",
- "3.7a1", "3.7a2pre", "3.7a2", "3.7a3pre", "3.7a3", "3.7a4pre",
- "3.7a4", "3.7a5pre", "3.7a5", "3.7a6pre", "4.0b1", "4.0b2pre",
- "4.0b2", "4.0b3pre", "4.0b3", "4.0b4pre", "4.0b4", "4.0b5pre",
- "4.0b5", "4.0b6pre", "4.0b6", "4.0b7pre", "4.0b7", "4.0b8pre",
- "4.0b8", "4.0b9pre", "4.0b9", "4.0b10pre", "4.0b10", "4.0b11pre",
- "4.0b11", "4.0b12pre", "4.0b12", "4.0", "4.0.*", "4.2a1pre", "5.0a2",
- "5.0", "5.*", "6.0a1", "6.0a2", "6.0", "6.*", "7.0a1", "7.0a2", "7.0",
- "7.*", "8.0a1", "8.0a2", "8.0", "8.*", "9.0a1", "9.0a2", "9.0",
- "9.*", "10.0a1", "10.0a2", "10.0", "10.*", "11.0a1", "11.0a2", "11.0",
- "11.*", "12.0a1", "12.0a2", "12.0", "12.*", "13.0a1", "13.0a2", "13.0",
- "13.*", "14.0a1", "14.0a2", "14.0", "14.*", "15.0a1", "15.0a2", "15.0",
- "15.*", "16.0a1"]
- },
- "2":{"name":"Mozilla",
- "guid":"{86c18b42-e466-45a9-ae7a-9b95ba6f5640}",
- "versions":
- ["1.0", "1.1", "1.3", "1.4", "1.4.1", "1.5", "1.5.1", "1.6", "1.7",
- "1.7.7", "1.7.*", "1.8a", "1.8a3", "1.8a4", "1.8a5", "1.8a6", "1.8b1",
- "1.8", "1.8+"]
- },
- "3":{"name":"Thunderbird",
- "guid":"{3550f703-e582-4d05-9a08-453d09bdfdc6}",
- "versions":
- ["0.3", "0.4", "0.5", "0.6", "0.7", "0.7.1", "0.7.1+", "0.7.2",
- "0.7.3", "0.7.3+", "0.7+", "0.8", "0.8+", "0.9", "0.9+", "1.0",
- "1.0.2", "1.0.6", "1.0.8", "1.1a1", "1.0+", "1.5b", "1.5b1", "1.5b2",
- "1.5", "1.5.0.4", "1.5.0.5", "1.5.0.*", "2.0a1", "2.0b1", "2.0b2",
- "2.0", "2.0.0.8", "2.0.0.*", "3.0a1pre", "3.0a1", "3.0a2pre", "3.0a2",
- "3.0a3", "3.0b1pre", "3.0b1", "3.0b2pre", "3.0b2", "3.0b3pre",
- "3.0b3", "3.0b4pre", "3.0b4", "3.0pre", "3.0", "3.0.1", "3.0.*",
- "3.1a1pre", "3.1a1", "3.1b1pre", "3.1b1", "3.1b2pre", "3.1b2",
- "3.1pre", "3.1", "3.1.*", "3.2a1pre", "3.3a1pre", "3.3a1", "3.3a2pre",
- "3.3a2", "3.3a3pre", "3.3a3", "3.3a4pre", "5.0b1", "5.0b2pre", "5.0",
- "5.*", "6.0a1", "6.0a2", "6.0", "6.*", "7.0a1", "7.0a2", "7.*",
- "8.0a1", "8.0a2", "8.0", "8.*", "9.0a1", "9.0a2", "9.0", "9.*",
- "10.0a1", "10.0a2", "10.0", "10.*", "11.0a1", "11.0a2", "11.0",
- "11.*", "12.0a1", "12.0a2", "12.0", "12.*", "13.0a1", "13.0a2", "13.0",
- "13.*", "14.0a1", "14.0a2", "14.0", "14.*", "15.0a1", "15.0a2", "15.0",
- "15.*", "16.0a1"]
- },
- "4":{"name":"Sunbird",
- "guid":"{718e30fb-e89b-41dd-9da7-e25a45638b28}",
- "versions":
- ["0.2", "0.3a1", "0.3a2", "0.2+", "0.3", "0.3.1", "0.4a1", "0.5",
- "0.6a1", "0.7pre", "0.7", "0.8pre", "0.8", "0.9pre", "0.9", "1.0b1",
- "1.0pre", "5.0b2pre"]
- },
- "5":{"name":"SeaMonkey",
- "guid":"{92650c4d-4b8e-4d2a-b7eb-24ecf4f6b63a}",
- "versions":
- ["1.0a", "1.0", "1.0.*", "1.1a", "1.1b", "1.1", "1.1.*", "1.5a",
- "2.0a", "2.0a1pre", "2.0a1", "2.0a2pre", "2.0a2", "2.0a3pre", "2.0a3",
- "2.0b1pre", "2.0b1", "2.0b2pre", "2.0b2", "2.0pre", "2.0", "2.0.1",
- "2.0.*", "2.1a1pre", "2.1a1", "2.1a2pre", "2.1a2", "2.1a3pre",
- "2.1a3", "2.1b1pre", "2.1b1", "2.1b2pre", "2.1b2", "2.1b3pre",
- "2.1b3", "2.1", "2.1.*", "2.2a1pre", "2.2", "2.2.*", "2.3a2", "2.3",
- "2.3.*", "2.4a1", "2.4a2", "2.5a1", "2.5a2", "2.6a1", "2.6a2", "2.6",
- "2.6.*", "2.7a1", "2.7a2", "2.7", "2.7.*", "2.8a1", "2.8a2", "2.8",
- "2.8.*", "2.9a1", "2.9a2", "2.9", "2.9.*", "2.10a1", "2.10a2", "2.10",
- "2.10.*", "2.11a1", "2.11a2", "2.11", "2.11.*", "2.12a1", "2.12a2",
- "2.12", "2.12.*", "2.13a1"]
- },
- "6":{"name":"Mobile",
- "guid":"{a23983c0-fd0e-11dc-95ff-0800200c9a66}",
- "versions":
- ["0.1", "0.7", "1.0a1", "1.0b1", "1.0b2pre", "1.0b2", "1.0b6pre",
- "1.0", "1.0.*", "1.1a1", "1.1a2pre", "1.1b1", "1.1", "1.1.*",
- "2.0a1pre", "2.0a1", "4.0b1pre", "4.0b1", "4.0b2pre", "4.0b2",
- "4.0b3pre", "4.0b3", "4.0b4pre", "4.0b4", "4.0b5pre", "4.0b5",
- "4.0b6pre", "4.0", "4.0.*", "4.1a1pre", "5.0a2", "5.0", "5.*",
- "6.0a1", "6.0a2", "6.0", "6.*", "7.0a1", "7.0a2", "7.0", "7.*",
- "8.0a1", "8.0a2", "8.0", "8.*", "9.0a1", "9.0a2", "9.0", "9.*",
- "10.0a1", "10.0a2", "10.0", "10.*", "11.0a1", "11.0a2", "11.0",
- "11.*", "12.0a1", "12.0a2", "12.0", "12.*", "13.0a1", "13.0a2",
- "13.0", "13.*", "14.0a1", "14.0a2", "14.0", "14.*", "15.0a1",
- "15.0a2", "15.0", "15.*", "16.0a1"]
- },
- "7":{"name":"Android",
- "guid":"{aa3c5121-dab2-40e2-81ca-7ea25febc110}",
- "versions":
- ["10.0a1", "10.0a2", "10.0", "10.*", "11.0a1", "11.0a2", "11.0",
- "11.*", "12.0a1", "12.0a2", "12.0", "12.*", "13.0a1", "13.0a2",
- "13.0", "13.*", "14.0a1"]
- }
-}
@@ -1,240 +0,0 @@
-from validator.contextgenerator import ContextGenerator
-
-
-class ChromeManifest(object):
- """This class enables convenient parsing and iteration of
- chrome.manifest files."""
-
- def __init__(self, data, path):
- self.context = ContextGenerator(data)
- self.lines = data.split("\n")
-
- # Extract the data from the triples in the manifest
- triples = []
- counter = 0
-
- for line in self.lines:
- line = line.strip()
-
- counter += 1
-
- # Skip weird lines.
- if line.startswith("#"):
- continue
-
- triple = line.split(None, 2)
- if not triple:
- continue
- elif len(triple) == 2:
- triple.append("")
- if len(triple) < 3:
- continue
-
- triples.append({"subject": triple[0],
- "predicate": triple[1],
- "object": triple[2],
- "line": counter,
- "filename": path,
- "context": self.context})
-
- self.triples = triples
-
- def get_value(self, subject=None, predicate=None, object_=None):
- """Returns the first triple value matching the given subject,
- predicate, and/or object"""
-
- for triple in self.triples:
-
- # Filter out non-matches
- if (subject and triple["subject"] != subject) or \
- (predicate and triple["predicate"] != predicate) or \
- (object_ and triple["object"] != object_): # pragma: no cover
- continue
-
- # Return the first found.
- return triple
-
- return None
-
- def get_objects(self, subject=None, predicate=None):
- """Returns a generator of objects that correspond to the
- specified subjects and predicates."""
-
- for triple in self.triples:
-
- # Filter out non-matches
- if (subject and
- triple["subject"] != subject) or \
- (predicate and
- triple["predicate"] != predicate): # pragma: no cover
- continue
-
- yield triple["object"]
-
- def get_triples(self, subject=None, predicate=None, object_=None):
- """Returns triples that correspond to the specified subject,
- predicates, and objects."""
-
- for triple in self.triples:
-
- # Filter out non-matches
- if subject is not None and triple["subject"] != subject:
- continue
- if predicate is not None and triple["predicate"] != predicate:
- continue
- if object_ is not None and triple["object"] != object_:
- continue
-
- yield triple
-
- def get_applicable_overlays(self, error_bundle):
- """
- Given an error bundle, a list of overlays that are present in the
- current package or subpackage are returned.
- """
-
- content_paths = self.get_triples(subject="content")
- if not content_paths:
- return set()
-
- # Create some variables that will store where the applicable content
- # instruction path references and where it links to.
- chrome_path = ""
- content_root_path = "/"
-
- # Look through each of the listed packages and paths.
- for path in content_paths:
- chrome_name = path["predicate"]
- if not path["object"]:
- continue
- path_location = path["object"].strip().split()[0]
-
- # Handle jarred paths differently.
- if path_location.startswith("jar:"):
- if not error_bundle.is_nested_package():
- continue
-
- # Parse out the JAR and it's location within the chrome.
- split_jar_url = path_location[4:].split("!", 2)
- # Ignore invalid/unsupported JAR URLs.
- if len(split_jar_url) != 2:
- continue
-
- # Unpack the JAR URL.
- jar_path, package_path = split_jar_url
-
- # Ignore the instruction if the JAR it points to doesn't match
- # up with the current subpackage tree.
- if jar_path != error_bundle.package_stack[0]:
- continue
- chrome_path = self._url_chunk_join(chrome_name, package_path)
- # content_root_path stays at the default: /
-
- break
- else:
- # If we're in a subpackage, a content instruction referring to
- # the root of the package obviously doesn't apply.
- if error_bundle.is_nested_package():
- continue
-
- chrome_path = self._url_chunk_join(chrome_name, "content")
- content_root_path = "/%s/" % path_location.strip("/")
- break
-
- if not chrome_path:
- return set()
-
- applicable_overlays = set()
- chrome_path = "chrome://%s" % self._url_chunk_join(chrome_path + "/")
-
- for overlay in self.get_triples(subject="overlay"):
- if not overlay["object"]:
- error_bundle.error(
- err_id=("chromemanifest", "get_applicable_overalys",
- "object"),
- error="Overlay instruction missing a property.",
- description="When overlays are registered in a chrome "
- "manifest file, they require a namespace and "
- "a chrome URL at minimum.",
- filename=overlay["filename"],
- line=overlay["line"],
- context=self.context) #TODO(basta): Update this!
- continue
- overlay_url = overlay["object"].split()[0]
- if overlay_url.startswith(chrome_path):
- overlay_relative_path = overlay_url[len(chrome_path):]
- applicable_overlays.add("/%s" %
- self._url_chunk_join(content_root_path,
- overlay_relative_path))
-
- return applicable_overlays
-
- def reverse_lookup(self, state, path):
- """
- Returns a chrome URL for a given path, given the current package depth
- in an error bundle.
-
- State may either be an error bundle or the actual package stack.
- """
-
- # Make sure the path starts with a forward slash.
- if not path.startswith("/"):
- path = "/%s" % path
-
- # If the state is an error bundle, extract the package stack.
- if not isinstance(state, list):
- state = state.package_stack
-
- content_paths = self.get_triples(subject="content")
- for content_path in content_paths:
- chrome_name = content_path["predicate"]
- if not content_path["object"]:
- continue
- path_location = content_path["object"].split()[0]
-
- if path_location.startswith("jar:"):
- if not state:
- continue
-
- # Parse out the JAR and it's location within the chrome.
- split_jar_url = path_location[4:].split("!", 2)
- # Ignore invalid/unsupported JAR URLs.
- if len(split_jar_url) != 2:
- continue
-
- # Unpack the JAR URL.
- jar_path, package_path = split_jar_url
-
- if jar_path != state[0]:
- continue
-
- return "chrome://%s" % self._url_chunk_join(chrome_name,
- package_path,
- path)
- else:
- if state:
- continue
-
- path_location = "/%s/" % path_location.strip("/")
- if not path.startswith(path_location):
- continue
-
- sliced_path = "/%s" % path[len(path_location):]
-
- return "chrome://%s" % self._url_chunk_join(chrome_name,
- sliced_path)
-
- return None
-
- def _url_chunk_join(self, *args):
- """Join the arguments together to form a predictable URL chunk."""
- # Strip slashes from either side of each path piece.
- pathlets = map(lambda s: s.strip("/"), args)
- # Remove empty pieces.
- pathlets = filter(None, pathlets)
- url = "/".join(pathlets)
- # If this is a directory, add a trailing slash.
- if args[-1].endswith("/"):
- url = "%s/" % url
- return url
-
Oops, something went wrong.

2 comments on commit b38db0c

Contributor
cvan commented on b38db0c Aug 1, 2012

r-

Owner

You're the worst.

Please sign in to comment.