test_bug1042436.xul 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?xml version="1.0"?>
  2. <?xml-stylesheet type="text/css" href="chrome://global/skin"?>
  3. <?xml-stylesheet type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"?>
  4. <!--
  5. https://bugzilla.mozilla.org/show_bug.cgi?id=1042436
  6. -->
  7. <window title="Mozilla Bug 1042436"
  8. xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
  9. <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
  10. <!-- test results are displayed in the html:body -->
  11. <body xmlns="http://www.w3.org/1999/xhtml">
  12. <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1042436"
  13. target="_blank">Mozilla Bug 1042436</a>
  14. </body>
  15. <!-- test code goes here -->
  16. <script type="application/javascript">
  17. <![CDATA[
  18. /** Test for Bug 1042436 **/
  19. SimpleTest.waitForExplicitFinish();
  20. const Cu = Components.utils;
  21. var contentSb = Cu.Sandbox('http://www.example.com');
  22. var nonXrayableObj = new contentSb.WeakMap();
  23. nonXrayableObj.wrappedJSObject.someExpandoProperty = 42;
  24. nonXrayableObj.wrappedJSObject.someOtherExpandoProperty = 52;
  25. SimpleTest.expectConsoleMessages(function() {
  26. nonXrayableObj.someExpandoProperty;
  27. nonXrayableObj.someOtherExpandoProperty;
  28. var chromeSb = Cu.Sandbox(this);
  29. var contentObjWithGetter = contentSb.eval('({ get getterProp() {return 42;}, valueProp: 42 })');
  30. is(contentObjWithGetter.wrappedJSObject.getterProp, 42, "Getter prop set up correctly");
  31. is(contentObjWithGetter.getterProp, undefined, "Xrays work right");
  32. is(contentObjWithGetter.valueProp, 42, "Getter prop set up correctly");
  33. chromeSb.contentObjWithGetter = contentObjWithGetter;
  34. Cu.evalInSandbox('contentObjWithGetter.getterProp; contentObjWithGetter.valueProp; contentObjWithGetter.getterProp;',
  35. chromeSb, "1.7", "http://phony.example.com/file.js", 99);
  36. },
  37. [{ errorMessage: /property "someExpandoProperty" \(reason: object is not safely Xrayable/, sourceName: /test_bug1042436/, isWarning: true },
  38. { errorMessage: /property "getterProp" \(reason: property has accessor/, sourceName: /phony/, lineNumber: 99, isWarning: true } ],
  39. SimpleTest.finish.bind(SimpleTest));
  40. ]]>
  41. </script>
  42. </window>