/Tests/Manual/FF4096Test/AppController.j

http://github.com/cacaodev/cappuccino · Unknown · 47 lines · 32 code · 15 blank · 0 comment · 0 complexity · f8d3c4c13a6788355752c0e8db37e4c0 MD5 · raw file

  1. /*
  2. * AppController.j
  3. * FFTest
  4. *
  5. * Created by C. Blair Duncan on September 22, 2010.
  6. This test will verify that the framework is or is not returning truncated data in Firefox.
  7. See issue: http://githubissues.heroku.com/#280north/cappuccino/842
  8. */
  9. @import <Foundation/CPObject.j>
  10. @implementation AppController : CPObject
  11. {
  12. }
  13. - (void)applicationDidFinishLaunching:(CPNotification)aNotification
  14. {
  15. var theWindow = [[CPWindow alloc] initWithContentRect:CGRectMakeZero() styleMask:CPBorderlessBridgeWindowMask],
  16. contentView = [theWindow contentView];
  17. //due to FireFox x-site and not allowing local file bs, we just read a file from the resourse folder...
  18. var aURL = [CPURL URLWithString:[[CPBundle mainBundle] pathForResource:@"sampleXML.data"]];
  19. // note, normally you should not be using a synchronous request for your work
  20. var data = [CPURLConnection sendSynchronousRequest:[CPURLRequest requestWithURL:aURL] returningResponse:NULL];
  21. var dict = [CPPropertyListSerialization propertyListFromData:data format:CPPropertyListXMLFormat_v1_0];
  22. var theData = [dict valueForKey:@"LongString"];
  23. alert("Read " + theData.length + " bytes, \(should be 8122\)");
  24. var label = [[CPTextField alloc] initWithFrame:[contentView bounds]];
  25. [label setLineBreakMode:CPLineBreakByWordWrapping];
  26. [label setStringValue:theData];
  27. [label setFont:[CPFont systemFontOfSize:14.0]];
  28. [label setAutoresizingMask:CPViewWidthSizable | CPViewHeightSizable];
  29. [contentView addSubview:label];
  30. [theWindow orderFront:self];
  31. }
  32. @end